regcomp.c: Fix regression memory leak
authorKarl Williamson <public@khwilliamson.com>
Thu, 19 May 2011 03:57:25 +0000 (21:57 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 19 May 2011 04:53:07 +0000 (22:53 -0600)
I carelessly added this memory leak which happens in a bracketed
character class under /i when there is both a above 255 code point
listed plus one of the several below 256 code points that participate
in a fold with ones above 256.

For 5.16, as the use of the inversion list data structure expands, an
automatic method of freeing space will need to be put in place.  But
this should be sufficient for 5.14.1.

regcomp.c

index cc04524..08cf6a9 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10271,7 +10271,9 @@ parseit:
     /* Combine the two lists into one. */
     if (l1_fold_invlist) {
        if (nonbitmap) {
-           nonbitmap = invlist_union(nonbitmap, l1_fold_invlist);
+           HV* temp = invlist_union(nonbitmap, l1_fold_invlist);
+           invlist_destroy(nonbitmap);
+           nonbitmap = temp;
        }
        else {
            nonbitmap = l1_fold_invlist;