Browse Source

- MFH: Fixed bug #46108 (DateTime - Memory leak when unserializing)

experimental/5.3-FPM
Felipe Pena 18 years ago
parent
commit
b33f88607a
  1. 1
      NEWS
  2. 6
      ext/date/php_date.c
  3. 19
      ext/date/tests/bug46108.phpt

1
NEWS

@ -24,6 +24,7 @@ PHP NEWS
- Fixed bug #47516 (nowdoc can not be embed in heredoc but can be embed in
double quote). (Dmitry)
- Fixed bug #47038 (Memory leak in include). (Dmitry)
- Fixed bug #46108 (DateTime - Memory leak when unserializing). (Felipe)
- Fixed bug #44861 (scrollable cursor don't work with pgsql). (Matteo)
- Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()). (Matteo)
- Fixed bug #44173 (PDO->query() parameter parsing/checking needs an

6
ext/date/php_date.c

@ -2268,10 +2268,6 @@ static void date_object_free_storage_period(void *object TSRMLS_DC)
/* Advanced Interface */
static zval * date_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC)
{
if (!object) {
ALLOC_ZVAL(object);
}
Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
Z_SET_REFCOUNT_P(object, 1);
@ -2461,12 +2457,14 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
ALLOC_INIT_ZVAL(tmp_obj);
tzobj = zend_object_store_get_object(date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC);
tzobj->type = TIMELIB_ZONETYPE_ID;
tzobj->tzi.tz = tzi;
tzobj->initialized = 1;
date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp_obj);
return 1;
}
}

19
ext/date/tests/bug46108.phpt

@ -0,0 +1,19 @@
--TEST--
Bug #46108 (DateTime - Memory leak when unserializing)
--FILE--
<?php
date_default_timezone_set('America/Sao_Paulo');
var_dump(unserialize(serialize(new Datetime)));
?>
--EXPECTF--
object(DateTime)#%d (3) {
[%u|b%"date"]=>
%string|unicode%(%d) "%s"
[%u|b%"timezone_type"]=>
int(%d)
[%u|b%"timezone"]=>
%string|unicode%(%d) "America/Sao_Paulo"
}
Loading…
Cancel
Save