[postgis-tickets] r17133 - Fix memory leak in case where valid WKT is
Paul Ramsey
pramsey at cleverelephant.ca
Thu Jan 10 10:21:41 PST 2019
Author: pramsey
Date: 2019-01-10 10:21:41 -0800 (Thu, 10 Jan 2019)
New Revision: 17133
Modified:
branches/2.4/liblwgeom/lwin_wkt_parse.c
Log:
Fix memory leak in case where valid WKT is
followed by garbage content
Closes #4273
Modified: branches/2.4/liblwgeom/lwin_wkt_parse.c
===================================================================
--- branches/2.4/liblwgeom/lwin_wkt_parse.c 2019-01-10 18:03:58 UTC (rev 17132)
+++ branches/2.4/liblwgeom/lwin_wkt_parse.c 2019-01-10 18:21:41 UTC (rev 17133)
@@ -175,6 +175,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,
@@ -183,13 +191,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