felipe                                   Wed, 23 Mar 2011 01:22:18 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=309580

Log:
- Fixed bug #54283 (new DatePeriod(NULL) causes crash)

Bug: http://bugs.php.net/54283 (error getting bug information)
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/date/php_date.c
    A   php/php-src/branches/PHP_5_3/ext/date/tests/bug54283.phpt
    U   php/php-src/trunk/ext/date/php_date.c
    A   php/php-src/trunk/ext/date/tests/bug54283.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2011-03-23 00:51:22 UTC (rev 309579)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-03-23 01:22:18 UTC (rev 309580)
@@ -13,6 +13,7 @@
   . 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)

Modified: php/php-src/branches/PHP_5_3/ext/date/php_date.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/date/php_date.c    2011-03-23 00:51:22 UTC 
(rev 309579)
+++ php/php-src/branches/PHP_5_3/ext/date/php_date.c    2011-03-23 01:22:18 UTC 
(rev 309580)
@@ -3767,7 +3767,7 @@
        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);

Added: php/php-src/branches/PHP_5_3/ext/date/tests/bug54283.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/date/tests/bug54283.phpt                   
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/date/tests/bug54283.phpt   2011-03-23 
01:22:18 UTC (rev 309580)
@@ -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 ()"

Modified: php/php-src/trunk/ext/date/php_date.c
===================================================================
--- php/php-src/trunk/ext/date/php_date.c       2011-03-23 00:51:22 UTC (rev 
309579)
+++ php/php-src/trunk/ext/date/php_date.c       2011-03-23 01:22:18 UTC (rev 
309580)
@@ -3762,7 +3762,7 @@
        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);

Added: php/php-src/trunk/ext/date/tests/bug54283.phpt
===================================================================
--- php/php-src/trunk/ext/date/tests/bug54283.phpt                              
(rev 0)
+++ php/php-src/trunk/ext/date/tests/bug54283.phpt      2011-03-23 01:22:18 UTC 
(rev 309580)
@@ -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 ()"

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to