From: Paul Ramsey Date: Mon, 26 Feb 2018 19:51:25 +0000 (+0000) Subject: Fix memory corruption in case where lexer is interrupted mid-process X-Git-Tag: 2.5.0alpha~98 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7277392140290417418d638664e04a3f98c0d898;p=postgis Fix memory corruption in case where lexer is interrupted mid-process References #4017 git-svn-id: http://svn.osgeo.org/postgis/trunk@16422 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwin_wkt_lex.l b/liblwgeom/lwin_wkt_lex.l index 188b5a022..27e90d493 100644 --- a/liblwgeom/lwin_wkt_lex.l +++ b/liblwgeom/lwin_wkt_lex.l @@ -10,23 +10,6 @@ static YY_BUFFER_STATE wkt_yy_buf_state; - -/* -* Set up the lexer! -*/ -void wkt_lexer_init(char *src) -{ - wkt_yy_buf_state = wkt_yy_scan_string(src); -} - -/* -* Clean up the lexer! -*/ -void wkt_lexer_close() -{ - wkt_yy_delete_buffer(wkt_yy_buf_state); -} - /* * Handle errors due to unexpected junk in WKT strings. */ @@ -38,7 +21,6 @@ static void wkt_lexer_unknown() global_parser_result.errlocation = wkt_yylloc.last_column; } - /* * This macro is magically run after a rule is found but before the main * action is run. We use it to update the parse location information @@ -129,4 +111,21 @@ void *wkt_yyrealloc (void * ptr, yy_size_t size ) void wkt_yyfree (void * ptr ) { lwfree( (char *) ptr ); /* see wkt_yyrealloc() for (char *) cast */ -} \ No newline at end of file +} + +/* +* Set up the lexer! +*/ +void wkt_lexer_init(char *src) +{ + wkt_yy_buf_state = wkt_yy_scan_string(src); +} + +/* +* Clean up the lexer! +*/ +void wkt_lexer_close() +{ + wkt_yy_delete_buffer(wkt_yy_buf_state); +} +