From 5ca27b3f0f03ca44b67938c707be114ead1b0a21 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 23 Feb 2015 14:36:22 +0000 Subject: [PATCH] #3051, warning: 'end' may be used uninitialized in this function git-svn-id: http://svn.osgeo.org/postgis/trunk@13268 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/ptarray.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index 2a9d96ca6..a734c68d8 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -1273,14 +1273,24 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou int t, seg=-1; POINT4D start4d, end4d, projtmp; POINT2D proj, p; - const POINT2D *start, *end; + const POINT2D *start = NULL, *end = NULL; /* Initialize our 2D copy of the input parameter */ p.x = p4d->x; p.y = p4d->y; if ( ! proj4d ) proj4d = &projtmp; - + + /* If the pointarray has only one point, the nearest point is */ + /* just that point */ + if ( pa->npoints == 1 ) + { + getPoint4d_p(pa, 0, proj4d); + *mindistout = distance2d_pt_pt(&p, start); + return 0.0; + } + + /* Loop through pointarray looking for nearest segment */ start = getPoint2d_cp(pa, 0); for (t=1; tnpoints; t++) { -- 2.50.1