changeset 17723:9edabe80a556

regex: fix memory leak in compiler Fix by Andreas Schwab in: https://sourceware.org/ml/libc-alpha/2014-06/msg00503.html * lib/regcomp.c (parse_reg_exp): Deallocate partially constructed tree before returning error.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 11 Jul 2014 12:19:34 -0700
parents 20a6211f5d73
children 8526f2f0b117
files ChangeLog lib/regcomp.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 09 19:18:40 2014 -0400
+++ b/ChangeLog	Fri Jul 11 12:19:34 2014 -0700
@@ -1,3 +1,11 @@
+2014-07-11  Paul Eggert  <eggert@cs.ucla.edu>
+
+	regex: fix memory leak in compiler
+	Fix by Andreas Schwab in:
+	https://sourceware.org/ml/libc-alpha/2014-06/msg00503.html
+	* lib/regcomp.c (parse_reg_exp): Deallocate partially
+	constructed tree before returning error.
+
 2014-07-10  Assaf Gordon  <assafgordon@gmail.com>
 
 	announce-gen: avoid perl warnings
--- a/lib/regcomp.c	Wed Jul 09 19:18:40 2014 -0400
+++ b/lib/regcomp.c	Fri Jul 11 12:19:34 2014 -0700
@@ -2199,7 +2199,11 @@
 	{
 	  branch = parse_branch (regexp, preg, token, syntax, nest, err);
 	  if (BE (*err != REG_NOERROR && branch == NULL, 0))
-	    return NULL;
+	    {
+	      if (tree != NULL)
+		postorder (tree, free_tree, NULL);
+	      return NULL;
+	    }
 	}
       else
 	branch = NULL;