Skip to content

Commit

Permalink
test + fix for memory leak in midgard_datetime::__toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
indeyets committed Mar 11, 2011
1 parent ae5e8ee commit 9fd044e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion php_midgard_timestamp.c
Expand Up @@ -260,11 +260,12 @@ static PHP_METHOD(midgard_datetime, __toString)
/* Prepare DateTime::format argument */
zval *fmt;
MAKE_STD_ZVAL(fmt);
ZVAL_STRING(fmt, "c", 0);
ZVAL_STRING(fmt, "c", 1);

/* Invoke Datetime::format */
zval *retval = NULL;
zend_call_method_with_1_params(&zend_object, Z_OBJCE_P(zend_object), NULL, "format", &retval, fmt);
zval_ptr_dtor(&fmt);

RETURN_ZVAL(retval, 1, 1);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/001-midgard_datetime.phpt
Expand Up @@ -6,6 +6,7 @@ midgard_datetime tests
midgard.engine = On
midgard.http = Off
midgard.memory_debug = Off
report_memleaks = On
--FILE--
<?php
$date = new midgard_datetime();
Expand All @@ -20,6 +21,7 @@ echo $date->format("Y-m-d H:i:s")."\n";
$date->modify('+1 day');
echo $date->format("Y-m-d H:i:s")."\n";

echo ((string)$date)."\n";
?>
===DONE===
--EXPECTF--
Expand All @@ -28,4 +30,5 @@ echo $date->format("Y-m-d H:i:s")."\n";
2009-06-10 12:41:10
2009-01-28 12:41:10
2009-01-29 12:41:10
2009-01-29T12:41:10+00:00
===DONE===

0 comments on commit 9fd044e

Please sign in to comment.