From: Felipe Pena Date: Mon, 22 Sep 2008 13:06:29 +0000 (+0000) Subject: - Fixed bug #46088 (RegexIterator::accept - segfault) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~343 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac5d2bd5f0ebe7f110b14ed0df0cfbac4b76e81e;p=php - Fixed bug #46088 (RegexIterator::accept - segfault) --- 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-- +accept()); + +?> +--EXPECT-- +bool(false)