[postgis-tickets] r17131 - Remove memory leak in "junky wkt" case
Paul Ramsey
pramsey at cleverelephant.ca
Thu Jan 10 08:21:01 PST 2019
Author: pramsey
Date: 2019-01-10 08:21:01 -0800 (Thu, 10 Jan 2019)
New Revision: 17131
Modified:
branches/2.5/liblwgeom/lwin_wkt_parse.c
Log:
Remove memory leak in "junky wkt" case
References #4273
Modified: branches/2.5/liblwgeom/lwin_wkt_parse.c
===================================================================
--- branches/2.5/liblwgeom/lwin_wkt_parse.c 2019-01-09 20:34:17 UTC (rev 17130)
+++ branches/2.5/liblwgeom/lwin_wkt_parse.c 2019-01-10 16:21:01 UTC (rev 17131)
@@ -152,6 +152,14 @@
global_parser_result.message = parser_error_messages[PARSER_ERROR_OTHER];
global_parser_result.errlocation = wkt_yylloc.last_column;
}
+ /* Got a completed object parsed, but errored out after... */
+ /* Due to junk after the valid WKT, eg: "POINT(1 1) foobar" */
+ /* https://trac.osgeo.org/postgis/ticket/4273 */
+ if ( global_parser_result.errcode && ! parse_rv )
+ {
+ lwgeom_free(global_parser_result.geom);
+ global_parser_result.geom = NULL;
+ }
LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
global_parser_result.errlocation,
@@ -160,13 +168,13 @@
/* Copy the global values into the return pointer */
*parser_result = global_parser_result;
- wkt_yylex_destroy();
+ wkt_yylex_destroy();
return LW_FAILURE;
}
/* Copy the global value into the return pointer */
*parser_result = global_parser_result;
- wkt_yylex_destroy();
+ wkt_yylex_destroy();
return LW_SUCCESS;
}
More information about the postgis-tickets
mailing list