summaryrefslogtreecommitdiff
path: root/ext/pcre/pcre2lib/pcre2_substring.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-02-14 13:44:38 +0100
committerAnatol Belski <ab@php.net>2018-02-14 13:44:38 +0100
commit703e0370905bc432aa26d71803b3081851e99230 (patch)
tree028999b90d090d7979b82e04e0c5952421b2af0d /ext/pcre/pcre2lib/pcre2_substring.c
parent1cae6cf47b2dd2b41179b3c194dd353bb59792e6 (diff)
downloadphp-git-703e0370905bc432aa26d71803b3081851e99230.tar.gz
Upgrade bundled PCRE2 to 10.31
Diffstat (limited to 'ext/pcre/pcre2lib/pcre2_substring.c')
-rw-r--r--ext/pcre/pcre2lib/pcre2_substring.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/pcre/pcre2lib/pcre2_substring.c b/ext/pcre/pcre2lib/pcre2_substring.c
index f6d7c39722..ddf5774e15 100644
--- a/ext/pcre/pcre2lib/pcre2_substring.c
+++ b/ext/pcre/pcre2lib/pcre2_substring.c
@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
Written by Philip Hazel
Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016 University of Cambridge
+ New API code Copyright (c) 2016-2018 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -414,7 +414,12 @@ else
for (i = 0; i < count2; i += 2)
{
size = (ovector[i+1] > ovector[i])? (ovector[i+1] - ovector[i]) : 0;
- memcpy(sp, match_data->subject + ovector[i], CU2BYTES(size));
+
+ /* Size == 0 includes the case when the capture is unset. Avoid adding
+ PCRE2_UNSET to match_data->subject because it overflows, even though with
+ zero size calling memcpy() is harmless. */
+
+ if (size != 0) memcpy(sp, match_data->subject + ovector[i], CU2BYTES(size));
*listp++ = sp;
if (lensp != NULL) *lensp++ = size;
sp += size;