From c1b5abf6054aae82257247d80f04977e199646e7 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 22 Sep 2008 13:15:16 +0000 Subject: [PATCH] - MFH: Fixed bug #46088 (RegexIterator::accept - segfault) --- ext/spl/spl_iterators.c | 4 ++++ ext/spl/tests/bug46088.phpt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 ext/spl/tests/bug46088.phpt diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 8a66739056..0be0c8a2f0 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1363,6 +1363,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 = slprintf(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) -- 2.50.1