]> granicus.if.org Git - postgis/commitdiff
Tighten up parsing to account for strings
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 9 Jan 2019 16:42:23 +0000 (16:42 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 9 Jan 2019 16:42:23 +0000 (16:42 +0000)
with junk after valid geometry
References #4273

git-svn-id: http://svn.osgeo.org/postgis/trunk@17127 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_inout.c
postgis/lwgeom_ogc.c

index d822fc8029127823c2075b4759962cabf8742f8a..8588d46f29ed197d3c087326fdd5ae5622bd02f5 100644 (file)
@@ -143,7 +143,8 @@ Datum LWGEOM_in(PG_FUNCTION_ARGS)
        /* WKT then. */
        else
        {
-               if ( lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL) == LW_FAILURE )
+               int rv = lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL);
+               if ( rv == LW_FAILURE || lwg_parser_result.errcode )
                {
                        PG_PARSER_ERROR(lwg_parser_result);
                        PG_RETURN_NULL();
index 71c24b466f897da360aeacaaa71b497a9acd647d..b5168ebb47685e996090cdb981cfbb5b820588ba 100644 (file)
@@ -788,11 +788,13 @@ Datum LWGEOM_from_text(PG_FUNCTION_ARGS)
        LWGEOM_PARSER_RESULT lwg_parser_result;
        GSERIALIZED *geom_result = NULL;
        LWGEOM *lwgeom;
+       int rv;
 
        POSTGIS_DEBUG(2, "LWGEOM_from_text");
        POSTGIS_DEBUGF(3, "wkt: [%s]", wkt);
 
-       if (lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE)
+       rv = lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL);
+       if (rv == LW_FAILURE || lwg_parser_result.errcode)
                PG_PARSER_ERROR(lwg_parser_result);
 
        lwgeom = lwg_parser_result.geom;