PATCH: [perl #133175] script run free from wrong pool panic
authorKarl Williamson <khw@cpan.org>
Sat, 5 May 2018 03:26:31 +0000 (21:26 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 9 May 2018 21:37:46 +0000 (15:37 -0600)
Setting the pointer to NULL after freeing signals the code in later
interations that it has been freed already

No test is added because it could become outdated (not testing what it
was designed to test) with a new Unicode version changing the underlying
data.  This bug was discovered by testing on Unicode 7.0, and the data
changed so that there was not a problem by Unicode 10.0.

regexec.c

index 9a5e87e..56d5b10 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -10583,9 +10583,11 @@ Perl_isSCRIPT_RUN(pTHX_ const U8 * s, const U8 * send, const bool utf8_target)
             /* If there is only a single script in common, set to that.
              * Otherwise, use the intersection going forward */
             Safefree(intersection);
+            intersection = NULL;
             if (intersection_len == 1) {
                 script_of_run = script_of_char = new_overlap[0];
                 Safefree(new_overlap);
+                new_overlap = NULL;
             }
             else {
                 intersection = new_overlap;