Commit 6e21e3b6 authored by Paul Ramsey's avatar Paul Ramsey

Remove memory leak in "junky wkt" case

References #4273


git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17131 b70326c6-7e19-0410-871a-916f4a2858ee
parent 074a463b
Pipeline #42890659 passed with stage
in 23 minutes and 7 seconds
......@@ -152,6 +152,14 @@ int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int pars
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 @@ int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int pars
/* 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment