From 80136a51d882963652fbe267b39df5392c29b71e Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 20 Dec 2016 15:27:31 -0800 Subject: [PATCH] mb_tail_dda: some code forgot to check for null --- dda_queue.c | 2 +- gcode_process.c | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dda_queue.c b/dda_queue.c index 7f987c5..0ddd35c 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -67,7 +67,7 @@ void queue_step() { This needs no atomic protection, because we're in an interrupt already. */ - if ( ! mb_tail_dda->live) { + if (mb_tail_dda == NULL || ! mb_tail_dda->live) { if (mb_tail != mb_head) { mb_tail = MB_NEXT(mb_tail); mb_tail_dda = &(movebuffer[mb_tail]); diff --git a/gcode_process.c b/gcode_process.c index 73922c1..6378cdb 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -609,19 +609,21 @@ void process_gcode_command() { current_position.axis[Z], current_position.axis[E], current_position.F); - if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) { - sersendf_P(PSTR("Endpoint: X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}\n"), - mb_tail_dda->endpoint.axis[X], - mb_tail_dda->endpoint.axis[Y], - mb_tail_dda->endpoint.axis[Z], - mb_tail_dda->endpoint.axis[E], - mb_tail_dda->endpoint.F, - #ifdef ACCELERATION_REPRAP - mb_tail_dda->end_c - #else - mb_tail_dda->c - #endif - ); + if (mb_tail_dda != NULL) { + if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) { + sersendf_P(PSTR("Endpoint: X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}\n"), + mb_tail_dda->endpoint.axis[X], + mb_tail_dda->endpoint.axis[Y], + mb_tail_dda->endpoint.axis[Z], + mb_tail_dda->endpoint.axis[E], + mb_tail_dda->endpoint.F, + #ifdef ACCELERATION_REPRAP + mb_tail_dda->end_c + #else + mb_tail_dda->c + #endif + ); + } print_queue(); }