]> err.no Git - mapper/commitdiff
Zero the path data when allocating. Add one more check.
authorKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 15:55:54 +0000 (17:55 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Wed, 27 Feb 2008 15:55:54 +0000 (17:55 +0200)
src/path.c
src/path.h

index f5002ac6e00433772438a6a597a6827cc54fcacf..8876587918a341336c63376fc8e60fcbe8866da2 100644 (file)
@@ -70,6 +70,9 @@ while (wcurr!=path->wtail) {
        if (!wcurr)
                break;
 
+       if (!wcurr->point)
+               break;
+
        unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
        g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2);
        sum += calculate_distance(lat1, lon1, lat2, lon2);
index cba575b0abf962de0954c109a2011075ee0e6eff..108c25a03d27d224df914cc33139549d994b775c 100644 (file)
@@ -5,10 +5,10 @@
 #include <gtk/gtk.h>
 
 #define MACRO_PATH_INIT(path) { \
-    (path).head = (path).tail = g_new(Point, ARRAY_CHUNK_SIZE); \
+    (path).head = (path).tail = g_new0(Point, ARRAY_CHUNK_SIZE); \
     *((path).tail) = _point_null; \
     (path).cap = (path).head + ARRAY_CHUNK_SIZE; \
-    (path).whead = g_new(WayPoint, ARRAY_CHUNK_SIZE); \
+    (path).whead = g_new0(WayPoint, ARRAY_CHUNK_SIZE); \
     (path).wtail = (path).whead - 1; \
     (path).wcap = (path).whead + ARRAY_CHUNK_SIZE; \
 }