From 9ffc4029cb5c31df8ddbb9fa999e33531d0be4b4 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 27 Feb 2008 17:36:00 +0200 Subject: [PATCH] Check that waypoint->point is valid before using it. --- src/route.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/route.c b/src/route.c index 25a859b..1073a3c 100644 --- a/src/route.c +++ b/src/route.c @@ -488,7 +488,7 @@ guint64 nearest_squared; Point pos = { unitx, unity, 0, NAN }; wcurr = wnear = _route.whead; -if (wcurr && wcurr != _route.wtail) { +if (wcurr && wcurr->point && wcurr != _route.wtail) { nearest_squared = DISTANCE_SQUARED(pos, *(wcurr->point)); while (wcurr++ != _route.wtail) { @@ -500,13 +500,11 @@ if (wcurr && wcurr != _route.wtail) { } } -if (wnear) { +if (wnear && wnear->point) { /* Only use the waypoint if it is within a 6*_draw_width square drawn * around the position. This is consistent with select_poi(). */ - if (abs(unitx - wnear->point->unitx) < - pixel2unit(3 * _draw_width) - && abs(unity - wnear->point->unity) < - pixel2unit(3 * _draw_width)) + if (abs(unitx - wnear->point->unitx) < pixel2unit(3 * _draw_width) && + abs(unity - wnear->point->unity) < pixel2unit(3 * _draw_width)) return wnear; } -- 2.39.5