Browse Source

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.
mihtjel 4 years ago
parent
commit
50a6ffa952
No account linked to committer's email address
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      Marlin/src/gcode/gcode.cpp

+ 1
- 1
Marlin/src/gcode/gcode.cpp View File

1048
     char * const delim = strchr(gcode, '\n');         // Get address of next newline
1048
     char * const delim = strchr(gcode, '\n');         // Get address of next newline
1049
     if (delim) *delim = '\0';                         // Replace with nul
1049
     if (delim) *delim = '\0';                         // Replace with nul
1050
     parser.parse(gcode);                              // Parse the current command
1050
     parser.parse(gcode);                              // Parse the current command
1051
-    if (delim) *delim = '\n';                         // Put back the newline
1052
     process_parsed_command(true);                     // Process it
1051
     process_parsed_command(true);                     // Process it
1052
+    if (delim) *delim = '\n';                         // Put back the newline
1053
     if (!delim) break;                                // Last command?
1053
     if (!delim) break;                                // Last command?
1054
     gcode = delim + 1;                                // Get the next command
1054
     gcode = delim + 1;                                // Get the next command
1055
   }
1055
   }

Loading…
Cancel
Save