From 259d8f19b327c94921caa8584bf6c50cab696a74 Mon Sep 17 00:00:00 2001 From: mihtjel Date: Tue, 23 Mar 2021 07:00:22 +0100 Subject: [PATCH] Fix macros that call macros crashing (#21383) When macros call macros, the null termination should remain in place until the macro is completed, and only then put back. Otherwise, the macro handler interprets this as setting the macro called to a new value. --- Marlin/src/gcode/gcode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 4e324e7892..6290d7a1d5 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1048,8 +1048,8 @@ void GcodeSuite::process_subcommands_now(char * gcode) { char * const delim = strchr(gcode, '\n'); // Get address of next newline if (delim) *delim = '\0'; // Replace with nul parser.parse(gcode); // Parse the current command - if (delim) *delim = '\n'; // Put back the newline process_parsed_command(true); // Process it + if (delim) *delim = '\n'; // Put back the newline if (!delim) break; // Last command? gcode = delim + 1; // Get the next command }