com php-src: don't keep useless objects till the end of the script (destroy them immediately): ext/date/php_date.c ext/date/tests/bug 51866.phpt
| From: | Dmitry Stogov | Date: | Fri, 21 Mar 2014 11:32:02 +0000 |
| Subject: | com php-src: don't keep useless objects till the end of the script (destroy them immediately): ext/date/php_date.c ext/date/tests/bug 51866.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77571@lists.php.net to get a copy of this message | ||
Commit: 7ce06ee5a7a216671c40169fc3326ca3f6fd92cc
Author: Dmitry Stogov <dmitry@zend.com> Fri, 21 Mar 2014 15:32:02 +0400
Parents: ef6919e6f2ffc951b9014778f74e79c7a6fbe3eb
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7ce06ee5a7a216671c40169fc3326ca3f6fd92cc
Log:
don't keep useless objects till the end of the script (destroy them immediately)
Changed paths:
M ext/date/php_date.c
M ext/date/tests/bug51866.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 8c08ddb..9070c3b 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 8d765b0..01ca555 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"]=>