From 62d4a9d48d716db73227cf7bbf85ecd3e60ce5db Mon Sep 17 00:00:00 2001 From: Thomas Bonfort Date: Mon, 23 Jul 2012 12:14:16 +0200 Subject: [PATCH] avoid segfault on failed reprojected point (#4403) also add proj error message as to why reprojection failed --- mapgml.c | 9 +++++++-- mapproject.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mapgml.c b/mapgml.c index 3e8bd64556..2e1afc5fb9 100644 --- a/mapgml.c +++ b/mapgml.c @@ -1215,8 +1215,13 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces) #ifdef USE_PROJ /* project the shape into the map projection (if necessary), note that this projects the bounds as well */ - if(pszOutputSRS == pszMapSRS && msProjectionsDiffer(&(lp->projection), &(map->projection))) - msProjectShape(&lp->projection, &map->projection, &shape); + if(pszOutputSRS == pszMapSRS && msProjectionsDiffer(&(lp->projection), &(map->projection))) { + status = msProjectShape(&lp->projection, &map->projection, &shape); + if(status != MS_SUCCESS) { + msIO_fprintf(stream, "\n",msGetErrorString(",")); + continue; + } + } #endif /* start this feature */ diff --git a/mapproject.c b/mapproject.c index b2175d496e..131e6344f0 100644 --- a/mapproject.c +++ b/mapproject.c @@ -114,8 +114,10 @@ int msProjectPoint(projectionObj *in, projectionObj *out, pointObj *point) msReleaseLock( TLOCK_PROJ ); #endif - if( error || point->x == HUGE_VAL || point->y == HUGE_VAL ) + if( error || point->x == HUGE_VAL || point->y == HUGE_VAL ) { + msSetError(MS_PROJERR,"proj says: %s","msProjectPoint()",pj_strerrno(error)); return MS_FAILURE; + } if( pj_is_latlong(out->proj) ) { point->x *= RAD_TO_DEG;