Browse Source

Do not update saved_target if there's no current_block

There is a chance that current_block can be NULL despite
the queue being non-empty. This can happen early after a block has been
queued, but before the isr has picked it up for processing, and/or when
the current block is at the last step and is being discarded.

Check for current_block directly to avoid this race.
Yuri D'Elia 4 years ago
parent
commit
571906a494
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Firmware/Marlin_main.cpp

+ 2 - 2
Firmware/Marlin_main.cpp

@@ -10529,7 +10529,7 @@ void uvlo_()
 
     // save the global state at planning time
     uint16_t feedrate_bckp;
-    if (blocks_queued())
+    if (current_block)
     {
         memcpy(saved_target, current_block->gcode_target, sizeof(saved_target));
         feedrate_bckp = current_block->gcode_feedrate;
@@ -11129,7 +11129,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
 #endif
 
   // save the global state at planning time
-  if (blocks_queued())
+  if (current_block)
   {
       memcpy(saved_target, current_block->gcode_target, sizeof(saved_target));
       saved_feedrate2 = current_block->gcode_feedrate;