From 07cdfefdee8cf151453c6fb7f59b124aef9ce066 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 6 Nov 2006 17:21:05 +0000 Subject: [PATCH] Fixed bug #39350 (crash with implode("\n", array(false))). --- NEWS | 1 + ext/standard/string.c | 7 ++++++- ext/standard/tests/strings/bug39350.phpt | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug39350.phpt diff --git a/NEWS b/NEWS index 1753a73616..4e76b86428 100644 --- 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) diff --git a/ext/standard/string.c b/ext/standard/string.c index 7fe1e5ef4e..adf0077e4a 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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 index 0000000000..53d58b7099 --- /dev/null +++ b/ext/standard/tests/strings/bug39350.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #39350 (implode/join() crash on empty input strings) +--FILE-- + +--EXPECT-- +Done -- 2.40.0