From 2be3a6cc61736328b2c04cb4ad2b28ada776740e Mon Sep 17 00:00:00 2001 From: jvangrin Date: Mon, 4 Jul 2011 13:05:20 -0500 Subject: [PATCH] fixed null pointer dereference in planner_forward_pass_kernel --- planner.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/planner.c b/planner.c index 9dbe363..f21ced6 100644 --- a/planner.c +++ b/planner.c @@ -232,16 +232,18 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { if(!current) { return; } - // 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; + if(previous) { + // 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; + } } } }