From bc26b33161344e1fca0b668543529fb5d45eb6b4 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 27 Feb 2008 17:55:54 +0200 Subject: [PATCH] Zero the path data when allocating. Add one more check. --- src/path.c | 3 +++ src/path.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/path.c b/src/path.c index f5002ac..8876587 100644 --- a/src/path.c +++ b/src/path.c @@ -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); diff --git a/src/path.h b/src/path.h index cba575b..108c25a 100644 --- a/src/path.h +++ b/src/path.h @@ -5,10 +5,10 @@ #include #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; \ } -- 2.39.5