From 7ce06ee5a7a216671c40169fc3326ca3f6fd92cc Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 21 Mar 2014 15:32:02 +0400 Subject: [PATCH] don't keep useless objects till the end of the script (destroy them immediately) --- ext/date/php_date.c | 4 ++++ ext/date/tests/bug51866.phpt | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 8c08ddba20..9070c3ba4e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2605,6 +2605,7 @@ PHP_FUNCTION(date_create) php_date_instantiate(date_ce_date, return_value TSRMLS_CC); if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) { + zval_dtor(return_value); RETURN_FALSE; } } @@ -2625,6 +2626,7 @@ PHP_FUNCTION(date_create_immutable) php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC); if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) { + zval_dtor(return_value); RETURN_FALSE; } } @@ -2645,6 +2647,7 @@ PHP_FUNCTION(date_create_from_format) php_date_instantiate(date_ce_date, return_value TSRMLS_CC); if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) { + zval_dtor(return_value); RETURN_FALSE; } } @@ -2665,6 +2668,7 @@ PHP_FUNCTION(date_create_immutable_from_format) php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC); if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) { + zval_dtor(return_value); RETURN_FALSE; } } diff --git a/ext/date/tests/bug51866.phpt b/ext/date/tests/bug51866.phpt index 8d765b02f0..01ca555fd9 100644 --- a/ext/date/tests/bug51866.phpt +++ b/ext/date/tests/bug51866.phpt @@ -44,7 +44,7 @@ array(4) { string(6) "Y-m-d+" string(19) "2001-11-29 13:20:01" -object(DateTime)#2 (3) { +object(DateTime)#%d (3) { ["date"]=> string(19) "2001-11-29 %d:%d:%d" ["timezone_type"]=> @@ -70,7 +70,7 @@ array(4) { string(7) "Y-m-d +" string(19) "2001-11-29 13:20:01" -object(DateTime)#3 (3) { +object(DateTime)#%d (3) { ["date"]=> string(19) "2001-11-29 %d:%d:%d" ["timezone_type"]=> @@ -96,7 +96,7 @@ array(4) { string(6) "Y-m-d+" string(10) "2001-11-29" -object(DateTime)#2 (3) { +object(DateTime)#%d (3) { ["date"]=> string(19) "2001-11-29 %d:%d:%d" ["timezone_type"]=> @@ -139,7 +139,7 @@ array(4) { string(7) "Y-m-d +" string(11) "2001-11-29 " -object(DateTime)#2 (3) { +object(DateTime)#%d (3) { ["date"]=> string(19) "2001-11-29 %d:%d:%d" ["timezone_type"]=> -- 2.40.0