From: Paul Ramsey Date: Mon, 23 Feb 2015 14:36:22 +0000 (+0000) Subject: #3051, warning: 'end' may be used uninitialized in this function X-Git-Tag: 2.2.0rc1~643 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ca27b3f0f03ca44b67938c707be114ead1b0a21;p=postgis #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 --- 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++) {