]> granicus.if.org Git - php/commitdiff
- Fixed bug #54283 (new DatePeriod(NULL) causes crash)
authorFelipe Pena <felipe@php.net>
Wed, 23 Mar 2011 01:22:18 +0000 (01:22 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 23 Mar 2011 01:22:18 +0000 (01:22 +0000)
NEWS
ext/date/php_date.c
ext/date/tests/bug54283.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 5c67a490964c591ed116da6c7240098896f9047e..5d0c05338e73b0989afccd32ffc1b4163c54b86a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP                                                                        NEWS
   . Fixed bug #54340 (DateTime::add() method bug). (Adam)
   . Fixed bug #54316 (DateTime::createFromFormat does not handle trailing '|'
     correctly). (Adam)
+  . Fixed bug #54283 (new DatePeriod(NULL) causes crash). (Felipe)
 
 - DBA extension:
   . Fixed bug #54242 (dba_insert returns true if key already exists). (Felipe)
index 31470a5eec2d5951466811d7717e4dbf41655609..01e3c3318f32cbe8c245961fbbc84e27be461d0f 100644 (file)
@@ -3767,7 +3767,7 @@ PHP_METHOD(DatePeriod, __construct)
        dpobj = zend_object_store_get_object(getThis() TSRMLS_CC);
        dpobj->current = NULL;
 
-       if (isostr_len) {
+       if (isostr) {
                date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), &recurrences, isostr, isostr_len TSRMLS_CC);
                if (dpobj->start == NULL) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "The ISO interval '%s' did not contain a start date.", isostr);
diff --git a/ext/date/tests/bug54283.phpt b/ext/date/tests/bug54283.phpt
new file mode 100644 (file)
index 0000000..780d0fa
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #54283 (new DatePeriod(NULL) causes crash)
+--FILE--
+<?php
+
+try {
+       var_dump(new DatePeriod(NULL));
+} catch (Exception $e) {
+       var_dump($e->getMessage());
+}
+
+?>
+--EXPECTF--
+string(51) "DatePeriod::__construct(): Unknown or bad format ()"