From dd07c28a3257659ea897bad236687673f3401ebe Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 25 May 2015 18:07:54 +0000 Subject: [PATCH] Fix crasher found in garden tests git-svn-id: http://svn.osgeo.org/postgis/trunk@13554 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/ptarray.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index 4d3803b28..6e7a6c2b5 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -1304,17 +1304,19 @@ ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistou if ( ! proj4d ) proj4d = &projtmp; + start = getPoint2d_cp(pa, 0); + /* 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); + if ( mindistout ) + *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++) { double dist; -- 2.40.0