summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-09-15 10:39:34 -0600
committerFlorian Ragwitz <rafl@debian.org>2010-09-15 19:29:38 +0200
commit595598ee1f247e72e06e4cfbe0f98406015df5cc (patch)
tree0a64c52ba10b45cc0d7e08bb63837ba99659d6d9
parentad4e703e577a4db278c9a482f9057a9c9109c720 (diff)
downloadperl-595598ee1f247e72e06e4cfbe0f98406015df5cc.tar.gz
PATCH: regex longjmp flaws
The netbsd - 5.0.2 compiler pointed out that the recent changes to add longjmps to speed up some regex compilations can result in clobbering a few values. These depend on the compiled code, and so didn't show up in other compiler's warnings. This patch reinitializes them after a longjmp.
-rw-r--r--regcomp.c4
-rw-r--r--regcomp.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/regcomp.c b/regcomp.c
index 2ad4df9e7a..13f82e2496 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4317,6 +4317,8 @@ Perl_re_compile(pTHX_ SV * const pattern, U32 pm_flags)
JMPENV_JUMP(jump_ret);
}
+ GET_RE_DEBUG_FLAGS;
+
/* It's possible to write a regexp in ascii that represents Unicode
codepoints outside of the byte range, such as via \x{100}. If we
detect such a sequence we have to convert the entire pattern to utf8
@@ -4327,7 +4329,7 @@ Perl_re_compile(pTHX_ SV * const pattern, U32 pm_flags)
-- dmq */
DEBUG_PARSE_r(PerlIO_printf(Perl_debug_log,
"UTF8 mismatch! Converting to utf8 for resizing and compile\n"));
- exp = (char*)Perl_bytes_to_utf8(aTHX_ (U8*)exp, &len);
+ exp = (char*)Perl_bytes_to_utf8(aTHX_ (U8*)SvPV(pattern, plen), &len);
xend = exp + len;
RExC_orig_utf8 = RExC_utf8 = 1;
SAVEFREEPV(exp);
diff --git a/regcomp.h b/regcomp.h
index 1ef9d2daee..362a8ed0bd 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -767,9 +767,11 @@ re.pm, especially to the documentation.
if (re_debug_flags & RE_DEBUG_EXTRA_GPOS) x )
/* initialization */
-/* get_sv() can return NULL during global destruction. */
+/* get_sv() can return NULL during global destruction. re_debug_flags can get
+ * clobbered by a longjmp, so must be initialized */
#define GET_RE_DEBUG_FLAGS DEBUG_r({ \
SV * re_debug_flags_sv = NULL; \
+ re_debug_flags = 0; \
re_debug_flags_sv = get_sv(RE_DEBUG_FLAGS, 1); \
if (re_debug_flags_sv) { \
if (!SvIOK(re_debug_flags_sv)) \