iliaa Tue Jan 10 16:14:45 2006 UTC
Modified files:
/php-src/main/streams filter.c
/php-src/ext/standard/tests/filters bug35916.phpt
Log:
MFB51: Fixed bug #35916 (Duplicate calls to stream_bucket_append() lead to
a crash).
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.19&r2=1.20&diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.19 php-src/main/streams/filter.c:1.20
--- php-src/main/streams/filter.c:1.19 Sun Jan 1 13:09:57 2006
+++ php-src/main/streams/filter.c Tue Jan 10 16:14:45 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filter.c,v 1.19 2006/01/01 13:09:57 sniper Exp $ */
+/* $Id: filter.c,v 1.20 2006/01/10 16:14:45 iliaa Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -273,6 +273,10 @@
PHPAPI void php_stream_bucket_append(php_stream_bucket_brigade *brigade,
php_stream_bucket *bucket TSRMLS_DC)
{
+ if (brigade->tail == bucket) {
+ return;
+ }
+
bucket->prev = brigade->tail;
bucket->next = NULL;
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/tests/filters/bug35916.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/filters/bug35916.phpt
diff -u /dev/null php-src/ext/standard/tests/filters/bug35916.phpt:1.2
--- /dev/null Tue Jan 10 16:14:45 2006
+++ php-src/ext/standard/tests/filters/bug35916.phpt Tue Jan 10 16:14:45 2006
@@ -0,0 +1,42 @@
+--TEST--
+Bug #35916 (Duplicate calls to stream_bucket_append() lead to a crash)
+--FILE--
+<?php
+$file = dirname(__FILE__) . "/bug35916.txt";
[EMAIL PROTECTED]($file);
+
+class strtoupper_filter extends php_user_filter
+{
+ function filter($in, $out, &$consumed, $closing)
+ {
+ while($bucket=stream_bucket_make_writeable($in)) {
+ $bucket->data = strtoupper($bucket->data);
+ $consumed += $bucket->datalen;
+ stream_bucket_append($out, $bucket);
+ stream_bucket_append($out, $bucket);
+ }
+ return PSFS_PASS_ON;
+ }
+ function onCreate()
+ {
+ echo "fffffffffff\n";
+ }
+ function onClose()
+ {
+ echo "hello\n";
+ }
+}
+
+stream_filter_register("strtoupper", "strtoupper_filter");
+$fp=fopen($file, "w");
+stream_filter_append($fp, "strtoupper");
+fread($fp, 1024);
+fwrite($fp, "Thank you\n");
+fclose($fp);
+readfile($file);
+unlink($file);
+?>
+--EXPECT--
+fffffffffff
+hello
+THANK YOU
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php