#46088 [NEW]: RegexIterator::accept - segfault
| From: | felipe@php.net | Date: | Mon, 15 Sep 2008 22:52:13 +0000 |
| Subject: | #46088 [NEW]: RegexIterator::accept - segfault | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-129003@lists.php.net to get a copy of this message | ||
From: felipe@php.net
Operating system:
PHP version: 5.3CVS-2008-09-15 (CVS)
PHP Bug Type: SPL related
Bug description: RegexIterator::accept - segfault
Description:
------------
A simple detail:
Index: ext/spl/spl_iterators.c
===================================================================
RCS file: /repository/php-src/ext/spl/spl_iterators.c,v
retrieving revision 1.73.2.30.2.28.2.14
diff -u -p -r1.73.2.30.2.28.2.14 spl_iterators.c
--- ext/spl/spl_iterators.c 9 Sep 2008 19:44:15 -0000
1.73.2.30.2.28.2.14
+++ ext/spl/spl_iterators.c 15 Sep 2008 22:46:02 -0000
@@ -1690,6 +1690,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);
Reproduce code:
---------------
<?php
$x = new RegexIterator(new ArrayIterator(range(1, 10)), '/\d/');
var_dump($x->accept());
?>
Using the flag RegexIterator::USE_KEY too.
Actual result:
--------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1211655776 (LWP 768)]
zend_make_printable_zval (expr=0x0, expr_copy=0xbf8b9360,
use_copy=0xbf8b9374) at /home/felipe/dev/php5/Zend/zend.c:208
208 if (Z_TYPE_P(expr)==IS_STRING) {
(gdb) bt
#0 zend_make_printable_zval (expr=0x0, expr_copy=0xbf8b9360,
use_copy=0xbf8b9374) at /home/felipe/dev/php5/Zend/zend.c:208
#1 0x081941d0 in zim_spl_RegexIterator_accept (ht=0,
return_value=0x8786d34, return_value_ptr=0x0, this_ptr=0x8785de8,
return_value_used=1,
tsrm_ls=0x8642050) at
/home/felipe/dev/php5/ext/spl/spl_iterators.c:1704
#2 0x0834e7f0 in zend_do_fcall_common_helper_SPEC
(execute_data=0x87b82d8, tsrm_ls=0x8642050) at
/home/felipe/dev/php5/Zend/zend_vm_execute.h:315
#3 0x0833c913 in execute (op_array=0x8786238, tsrm_ls=0x8642050) at
/home/felipe/dev/php5/Zend/zend_vm_execute.h:104
#4 0x08316d8f in zend_execute_scripts (type=8, tsrm_ls=0x8642050,
retval=0x0, file_count=3) at /home/felipe/dev/php5/Zend/zend.c:1197
#5 0x082bdd0d in php_execute_script (primary_file=0xbf8bb848,
tsrm_ls=0x8642050) at /home/felipe/dev/php5/main/main.c:2075
#6 0x083aea45 in main (argc=2, argv=0xbf8bb9a4) at
/home/felipe/dev/php5/sapi/cli/php_cli.c:1130
--
Edit bug report at http://bugs.php.net/?id=46088&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46088&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46088&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46088&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46088&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=46088&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46088&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46088&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46088&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46088&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46088&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46088&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46088&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46088&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46088&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46088&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46088&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46088&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46088&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46088&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46088&r=mysqlcfg