]> granicus.if.org Git - php/commitdiff
Fixed bug #39350 (crash with implode("\n", array(false))).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 6 Nov 2006 17:21:05 +0000 (17:21 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 6 Nov 2006 17:21:05 +0000 (17:21 +0000)
NEWS
ext/standard/string.c
ext/standard/tests/strings/bug39350.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 1753a736162ba54326c9290883b467c62bba64c3..4e76b8642839d1dec565f49d6917d18970fa8088 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ PHP                                                                        NEWS
 - Fixed bug #39366 (imagerotate does not use alpha with angle > 45°) (Pierre)
 - Fixed bug #39362 (Added an option to imap_open/imap_reopen to control the 
   number of connection retries). (Ilia)
+- Fixed bug #39350 (crash with implode("\n", array(false))). (Ilia)
 - Fixed bug #39273 (imagecopyresized may ignore alpha channel) (Pierre)
 - Fixed bug #39364 (Removed warning on empty haystack inside mb_strstr()).
   (Ilia)
index 7fe1e5ef4e86dc7331814184c2f8f8ba23c8e781..adf0077e4a313e6ff9867ab54142a8e66e29aa29 100644 (file)
@@ -955,7 +955,12 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value TSRMLS_DC)
        }
        smart_str_0(&implstr);
 
-       RETURN_STRINGL(implstr.c, implstr.len, 0);
+       if (implstr.len) {
+               RETURN_STRINGL(implstr.c, implstr.len, 0);
+       } else {
+               smart_str_free(&implstr);
+               RETURN_EMPTY_STRING();
+       }
 }
 /* }}} */
 
diff --git a/ext/standard/tests/strings/bug39350.phpt b/ext/standard/tests/strings/bug39350.phpt
new file mode 100644 (file)
index 0000000..53d58b7
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #39350 (implode/join() crash on empty input strings)
+--FILE--
+<?php
+
+implode('', array(null));
+implode('', array(false));
+implode('', array(""));
+
+echo "Done\n";
+?>
+--EXPECT--     
+Done