fixed null pointer dereference in planner_forward_pass_kernel

This commit is contained in:
jvangrin 2011-07-04 13:05:20 -05:00
parent 67d7607e60
commit 2be3a6cc61

View File

@ -232,16 +232,18 @@ void planner_reverse_pass() {
// The kernel called by planner_recalculate() when scanning the plan from first to last entry. // 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) { void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
if(!current) { return; } if(!current) { return; }
// If the previous block is an acceleration block, but it is not long enough to if(previous) {
// complete the full speed change within the block, we need to adjust out entry // If the previous block is an acceleration block, but it is not long enough to
// speed accordingly. Remember current->entry_factor equals the exit factor of // complete the full speed change within the block, we need to adjust out entry
// the previous block. // speed accordingly. Remember current->entry_factor equals the exit factor of
if(previous->entry_factor < current->entry_factor) { // the previous block.
double max_entry_speed = max_allowable_speed(-settings.acceleration, if(previous->entry_factor < current->entry_factor) {
current->nominal_speed*previous->entry_factor, previous->millimeters); double max_entry_speed = max_allowable_speed(-settings.acceleration,
double max_entry_factor = max_entry_speed/current->nominal_speed; current->nominal_speed*previous->entry_factor, previous->millimeters);
if (max_entry_factor < current->entry_factor) { double max_entry_factor = max_entry_speed/current->nominal_speed;
current->entry_factor = max_entry_factor; if (max_entry_factor < current->entry_factor) {
current->entry_factor = max_entry_factor;
}
} }
} }
} }