From b12da0e421a16710bb653788f8b1ef00160328c2 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sat, 13 Mar 2021 12:08:43 +0100 Subject: [PATCH] Handle possible NULL-pointers for paths when rehashing the route --- src/dijkstrasearch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dijkstrasearch.c b/src/dijkstrasearch.c index 39e9a68..fa682c4 100644 --- a/src/dijkstrasearch.c +++ b/src/dijkstrasearch.c @@ -254,6 +254,14 @@ int dijkstra_search_route_to_geojson(struct dijkstra_search *search, if (node_last) { path_to_this = search->states[node_last->uid]->cheapest_path; path_to_next = search->states[node->uid]->cheapest_path; + if (!path_to_next) { + report(LL_CRITICAL, "INTERNAL ERROR: path_to_next is NULL"); + break; + } + if (!path_to_this) { + // This happens at the very beginning. + path_to_this = path_to_next; // Pretend we were already where we started. + } heading = atan2f((node->position.y - node_last->position.y), (node->position.x - node_last->position.x)) / (M_PI * 2) * 360; if (heading < 0.0)