From 88c557fc6c37e09ebf30897f6a6bd9810f624459 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 24 Jan 2012 00:09:53 +0000 Subject: [PATCH] Prevent people from inserting entries in spatial_ref_sys with no proj4text (#1150) git-svn-id: http://svn.osgeo.org/postgis/trunk@8910 b70326c6-7e19-0410-871a-916f4a2858ee --- libpgcommon/lwgeom_transform.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libpgcommon/lwgeom_transform.c b/libpgcommon/lwgeom_transform.c index e6a17ad5d..35b22afe7 100644 --- a/libpgcommon/lwgeom_transform.c +++ b/libpgcommon/lwgeom_transform.c @@ -368,9 +368,17 @@ char* GetProj4StringSPI(int srid) TupleDesc tupdesc = SPI_tuptable->tupdesc; SPITupleTable *tuptable = SPI_tuptable; HeapTuple tuple = tuptable->vals[0]; - - /* Make a projection object out of it */ - strncpy(proj_str, SPI_getvalue(tuple, tupdesc, 1), maxproj4len - 1); + char *proj4text = SPI_getvalue(tuple, tupdesc, 1); + + if ( proj4text ) + { + /* Make a projection object out of it */ + strncpy(proj_str, proj4text, maxproj4len - 1); + } + else + { + proj_str[0] = '\0'; + } } else { -- 2.40.0