From: Kaj-Michael Lang Date: Wed, 27 Feb 2008 15:55:54 +0000 (+0200) Subject: Zero the path data when allocating. Add one more check. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc26b33161344e1fca0b668543529fb5d45eb6b4;p=mapper Zero the path data when allocating. Add one more check. --- 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; \ }