]> err.no Git - mapper/commitdiff
Check that waypoint->point is valid before using it.
authorKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 15:36:00 +0000 (17:36 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 15:36:00 +0000 (17:36 +0200)
src/route.c

index 25a859bcee5fef2532a323201f0834b833a3d74d..1073a3c093f2e22a3a3a8d8b61f9624769e16ada 100644 (file)
@@ -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;
 }