summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-06-03 11:45:05 +0100
committerDavid Mitchell <davem@iabyn.com>2013-06-03 15:14:17 +0100
commit338e600ab7ba30b4ff23b08ecd51d91387a08853 (patch)
tree4234fa2c97dd36651051e51f966651ea4784f797 /regexec.c
parent46f1e811d4f7565aa05f3d7151074b8e8bcfa9b2 (diff)
downloadperl-338e600ab7ba30b4ff23b08ecd51d91387a08853.tar.gz
avoid undeflow in regex poscache count
reginfo->poscache_iter is used to count down to zero; at zero, the superlinear cache is enabled; and for values below zero the cache is tested. After I32_MAX iterations the count might wrap to a positive value on 32-bit systems. So don't do that.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/regexec.c b/regexec.c
index d29f6dd8f4..12548d5d21 100644
--- a/regexec.c
+++ b/regexec.c
@@ -5475,6 +5475,8 @@ NULL
if (reginfo->poscache_iter < 0) {
/* have we already failed at this position? */
I32 offset, mask;
+
+ reginfo->poscache_iter = -1; /* stop eventual underflow */
offset = (scan->flags & 0xf) - 1
+ (locinput - reginfo->strbeg)
* (scan->flags>>4);