From e2b3cd52d2e2cc375abbdff7dc7a368dcce4f40f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 26 Feb 2018 20:14:36 +0000 Subject: [PATCH] Fix memory corruption in case where lexer is interrupted mid-process References #4017 For 2.3 git-svn-id: http://svn.osgeo.org/postgis/branches/2.3@16426 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 2 ++ liblwgeom/lwin_wkt_lex.l | 37 ++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index 0999fd008..2f5cfa289 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PostGIS 2.3.7dev - #4020, Casting from box3d to geometry now returns correctly connected PolyhedralSurface (Matthias Bay) - #4025, Incorrect answers for temporally "amost overlapping" ranges + - #4017, lwgeom lexer memory corruption (Peter E) + PostGIS 2.3.6 2018/01/17 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); +} + -- 2.49.0