From 5466bc0c33e9be6d94bff2485e6fb697413bdec6 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Sun, 10 Jul 2011 21:54:03 +0200 Subject: [PATCH] fixed a nil dereferencing bug in planner_forward_pass_kernel thanks to jv4779 --- planner.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/planner.c b/planner.c index 549a016..5da1d3c 100644 --- a/planner.c +++ b/planner.c @@ -206,13 +206,15 @@ static void planner_forward_pass_kernel(block_t *previous, block_t *current, blo // If the previous block is an acceleration block, but it is not long enough to // complete the full speed change within the block, we need to adjust out entry // speed accordingly. Remember current->entry_factor equals the exit factor of - // the previous block. - if(previous->entry_factor < current->entry_factor) { - double max_entry_speed = max_allowable_speed(-settings.acceleration, - current->nominal_speed*previous->entry_factor, previous->millimeters); - double max_entry_factor = max_entry_speed/current->nominal_speed; - if (max_entry_factor < current->entry_factor) { - current->entry_factor = max_entry_factor; + // the previous block.ยจ + if(previous) { + if(previous->entry_factor < current->entry_factor) { + double max_entry_speed = max_allowable_speed(-settings.acceleration, + current->nominal_speed*previous->entry_factor, previous->millimeters); + double max_entry_factor = max_entry_speed/current->nominal_speed; + if (max_entry_factor < current->entry_factor) { + current->entry_factor = max_entry_factor; + } } } }