summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-09-22 13:06:29 +0000
committerFelipe Pena <felipe@php.net>2008-09-22 13:06:29 +0000
commitac5d2bd5f0ebe7f110b14ed0df0cfbac4b76e81e (patch)
treea274d4dd50a1b7b1b1876d02bd7ee21ef940e5f9 /ext/spl
parent0653e0a14280b1d0fa68dbada733a8771ba88722 (diff)
downloadphp-git-ac5d2bd5f0ebe7f110b14ed0df0cfbac4b76e81e.tar.gz
- Fixed bug #46088 (RegexIterator::accept - segfault)
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/spl_iterators.c4
-rw-r--r--ext/spl/tests/bug46088.phpt11
2 files changed, 15 insertions, 0 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index e6bfea8450..4f9953da28 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -1746,6 +1746,10 @@ SPL_METHOD(RegexIterator, accept)
int subject_len, use_copy, count, result_len;
zval subject_copy, zcount, *replacement;
+ if (intern->current.data == NULL) {
+ RETURN_FALSE;
+ }
+
if (intern->u.regex.flags & REGIT_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_LONG) {
subject_len = snprintf(tmp, sizeof(tmp), "%ld", intern->current.int_key);
diff --git a/ext/spl/tests/bug46088.phpt b/ext/spl/tests/bug46088.phpt
new file mode 100644
index 0000000000..4785377622
--- /dev/null
+++ b/ext/spl/tests/bug46088.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Bug #46088 (RegexIterator::accept - segfault)
+--FILE--
+<?php
+
+$x = new RegexIterator(new ArrayIterator(range(1, 10)), '/\d/');
+var_dump($x->accept());
+
+?>
+--EXPECT--
+bool(false)