Skip to content

Commit

Permalink
Fix macros that call macros crashing (#21383)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mihtjel authored and thinkyhead committed Apr 29, 2021
1 parent 9a1c4f9 commit 259d8f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 259d8f1

Please sign in to comment.