summaryrefslogtreecommitdiff
path: root/ext/pcre
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-09-20 08:10:44 +0000
committerAntony Dovgal <tony2001@php.net>2007-09-20 08:10:44 +0000
commitf67c0222feaa09813e8b05f669b3be17888db043 (patch)
tree5af3e1bf2f5d717108aeedc18a52a9780d03d042 /ext/pcre
parent47950d10cf450797ec917b7b8d0ad180d8ed316d (diff)
downloadphp-git-f67c0222feaa09813e8b05f669b3be17888db043.tar.gz
MFH
Diffstat (limited to 'ext/pcre')
-rw-r--r--ext/pcre/php_pcre.c5
-rw-r--r--ext/pcre/tests/006.phpt22
2 files changed, 26 insertions, 1 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 9a5b7a7bca..e48a97e043 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1220,8 +1220,11 @@ static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject,
efree(subject_value);
subject_value = result;
subject_len = *result_len;
+ } else {
+ efree(subject_value);
+ return NULL;
}
-
+
zend_hash_move_forward(Z_ARRVAL_P(regex));
}
diff --git a/ext/pcre/tests/006.phpt b/ext/pcre/tests/006.phpt
new file mode 100644
index 0000000000..d1282bf426
--- /dev/null
+++ b/ext/pcre/tests/006.phpt
@@ -0,0 +1,22 @@
+--TEST--
+preg_replace() with array of failing regular expressions
+--FILE--
+<?php
+
+$text = '[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]';
+$result = preg_replace(array('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU'), '', $text);
+var_dump($text);
+var_dump($result);
+
+$result = preg_replace('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '', $text);
+var_dump($text);
+var_dump($result);
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(58) "[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]"
+NULL
+string(58) "[CODE]&lt;td align=&quot;$stylevar[right]&quot;&gt;[/CODE]"
+NULL
+Done