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) {
}
}
-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;
}