diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-10-30 17:30:03 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-10-30 17:30:03 +0000 |
commit | 405ad6febcb15fa6fb38a946e91a33dfca39103c (patch) | |
tree | d9652e615cbf4bb692d61cde24e2e08d05d1384a /src/pcre2_substitute.c | |
parent | 0e3be373f5bb5220317246f9fa0e510b17a9615a (diff) | |
download | pcre2-405ad6febcb15fa6fb38a946e91a33dfca39103c.tar.gz |
Fix pcre2_substitute(): set zero-terminated length before UTF validity check.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@400 6239d852-aaf2-0410-a92c-79f79f948069
Diffstat (limited to 'src/pcre2_substitute.c')
-rw-r--r-- | src/pcre2_substitute.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pcre2_substitute.c b/src/pcre2_substitute.c index f6175c5..7cd8ccf 100644 --- a/src/pcre2_substitute.c +++ b/src/pcre2_substitute.c @@ -227,6 +227,12 @@ if (match_data == NULL) ovector = pcre2_get_ovector_pointer(match_data); ovector_count = pcre2_get_ovector_count(match_data); +/* Find lengths of zero-terminated strings and the end of the replacement. */ + +if (length == PCRE2_ZERO_TERMINATED) length = PRIV(strlen)(subject); +if (rlength == PCRE2_ZERO_TERMINATED) rlength = PRIV(strlen)(replacement); +repend = replacement + rlength; + /* Check UTF replacement string if necessary. */ #ifdef SUPPORT_UNICODE @@ -256,12 +262,6 @@ if ((options & PCRE2_SUBSTITUTE_EXTENDED) != 0) extended = TRUE; } -/* Find lengths of zero-terminated strings and the end of the replacement. */ - -if (length == PCRE2_ZERO_TERMINATED) length = PRIV(strlen)(subject); -if (rlength == PCRE2_ZERO_TERMINATED) rlength = PRIV(strlen)(replacement); -repend = replacement + rlength; - /* Copy up to the start offset */ if (start_offset > buff_length) goto NOROOM; |