regexec(): avoid uninit use of var
authorDavid Mitchell <davem@iabyn.com>
Fri, 19 Jul 2013 21:00:23 +0000 (22:00 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 28 Jul 2013 09:33:39 +0000 (10:33 +0100)
clang pointed out that

    if (...)
goto phooey;
    oldsave = PL_savestack_ix;
    ...
  phooey:
    LEAVE_SCOPE(oldsave);

could use oldsave uninitialised. clang 1, dave 0.

regexec.c

index 4d317cf..35851f6 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2278,6 +2278,13 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
         return 0;
     }
 
+    /* at the end of this function, we'll do a LEAVE_SCOPE(oldsave),
+     * which will call destuctors to reset PL_regmatch_state, free higher
+     * PL_regmatch_slabs, and clean up regmatch_info_aux and
+     * regmatch_info_aux_eval */
+
+    oldsave = PL_savestack_ix;
+
     s = startpos;
 
     if ((prog->extflags & RXf_USE_INTUIT)
@@ -2323,14 +2330,6 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
         }
     }
 
-
-    /* at the end of this function, we'll do a LEAVE_SCOPE(oldsave),
-     * which will call destuctors to reset PL_regmatch_state, free higher
-     * PL_regmatch_slabs, and clean up regmatch_info_aux and
-     * regmatch_info_aux_eval */
-
-    oldsave = PL_savestack_ix;
-
     multiline = prog->extflags & RXf_PMf_MULTILINE;
     
     if (strend - s < (minlen+(prog->check_offset_min<0?prog->check_offset_min:0))) {