diff options
author | Karl Williamson <public@khwilliamson.com> | 2014-02-19 21:14:44 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2014-02-19 21:29:23 -0700 |
commit | ed885487570a4a0046b0cb32a477526f8f016d93 (patch) | |
tree | 777e8a482999226c4889e36177047b4bffc62be2 /regcomp.c | |
parent | d3db5cfeb8346f308b4354ee1c8970ab9b526472 (diff) | |
download | perl-ed885487570a4a0046b0cb32a477526f8f016d93.tar.gz |
regcomp.c: Don't read uninitialized data
I keep forgetting that the OP of a regnode is not defined in Pass 1 of
the regex compiler. This is likely the cause of inconsistent results in
lib/locale.t, as valgrind shows there to be a read of uninitialized
data before this patch, and the result is randomly tainting when there
shouldn't be, consistent with the test failures.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -10882,7 +10882,7 @@ S_compute_EXACTish(pTHX_ RExC_state_t *pRExC_state) PERL_STATIC_INLINE void S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_state, regnode *node, I32* flagp, STRLEN len, UV code_point, - const bool downgradable) + bool downgradable) { /* This knows the details about sizing an EXACTish node, setting flags for * it (by setting <*flagp>, and potentially populating it with a single @@ -10916,6 +10916,12 @@ S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_state, PERL_ARGS_ASSERT_ALLOC_MAYBE_POPULATE_EXACT; + /* Don't bother to check for downgrading in PASS1, as it doesn't make any + * sizing difference, and is extra work that is thrown away */ + if (downgradable && ! PASS2) { + downgradable = FALSE; + } + if (! len_passed_in) { if (UTF) { if (UNI_IS_INVARIANT(code_point)) { @@ -11020,7 +11026,8 @@ S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_state, *flagp |= SIMPLE; } - if (OP(node) == EXACTFL) { + /* The OP may not be well defined in PASS1 */ + if (PASS2 && OP(node) == EXACTFL) { RExC_contains_locale = 1; } } |