From 0f333a60bf7e6058c05926c49fa2d4d4a623bb0d Mon Sep 17 00:00:00 2001 From: ScottW514 Date: Sun, 2 Aug 2026 13:39:27 -0400 Subject: [PATCH] gcode: guard NULL chained on_settings_changed in onSettingsChanged gc_init subscribes to grbl.on_settings_changed by capturing the previous handler to chain it. When no plugin or driver has subscribed before the first gc_init, the captured pointer is NULL and the chained call in onSettingsChanged dereferences it - every runtime $-setting write then crashes on drivers with no other subscriber (observed live with the Simulator). The core dispatcher already NULL-checks its own pointer; this adds the same guard to the chained tail. --- gcode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcode.c b/gcode.c index 464b228..0db532f 100644 --- a/gcode.c +++ b/gcode.c @@ -753,7 +753,8 @@ static void onSettingsChanged (settings_t *settings, settings_changed_flags_t ch if(changed.spindle || changed.restore_defaults) gc_spindle_off(); - settings_changed(settings, changed); + if(settings_changed) + settings_changed(settings, changed); } FLASHMEM void gc_init (bool stop)