[postgis-tickets] r16424 - Fix memory corruption in case where lexer is interrupted mid-process

Paul Ramsey pramsey at cleverelephant.ca
Mon Feb 26 12:03:29 PST 2018


Author: pramsey
Date: 2018-02-26 12:03:28 -0800 (Mon, 26 Feb 2018)
New Revision: 16424

Modified:
   branches/2.4/NEWS
   branches/2.4/liblwgeom/lwin_wkt_lex.l
Log:
Fix memory corruption in case where lexer is interrupted mid-process
References #4017
For 2.4 branch


Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2018-02-26 19:52:01 UTC (rev 16423)
+++ branches/2.4/NEWS	2018-02-26 20:03:28 UTC (rev 16424)
@@ -10,6 +10,7 @@
   - #3942, geojson: Do not include private header for json-c >= 0.13
            (Björn Esser)
   - #4025, Incorrect answers for temporally "amost overlapping" ranges
+  - #4017, lwgeom lexer memory corruption (Peter E)
 
  * Enhancements *
     - #3992, Use PKG_PROG_PKG_CONFIG macro from pkg.m4 to detect pkg-config

Modified: branches/2.4/liblwgeom/lwin_wkt_lex.l
===================================================================
--- branches/2.4/liblwgeom/lwin_wkt_lex.l	2018-02-26 19:52:01 UTC (rev 16423)
+++ branches/2.4/liblwgeom/lwin_wkt_lex.l	2018-02-26 20:03:28 UTC (rev 16424)
@@ -10,24 +10,7 @@
 
 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.
 */
 static void wkt_lexer_unknown() 
@@ -38,7 +21,6 @@
 	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_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); 
+} 
+



More information about the postgis-tickets mailing list