Edit report at http://bugs.php.net/bug.php?id=52808&edit=1

 ID:                 52808
 Updated by:         srina...@php.net
 Reported by:        j...@php.net
 Summary:            Negative intervals segfault
 Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   Debian stable
 PHP Version:        trunk-SVN-2010-09-09 (SVN)
 Assigned To:        derick
 Block user comment: N

 New Comment:

looks like my comment was lost in the previous post while uploading my
patch.



i was wondering, if dateinterval constructor accepts a general format of
date string. looking at the code it does not seem to be as well. 



manual suggests that you need to provide the input date in format
ISO8601 format. 



for example year 10th may, 2008 would be given as 

$a = new DateInterval("P2008Y5M11DT15H30M00S");



I haven't used this API much.So, I could be wrong.


Previous Comments:
------------------------------------------------------------------------
[2010-09-09 23:45:25] j...@php.net

Description:
------------
Creating an interval with a "negative duration" (i.e., "start" date
precedes "end" date) creates what appears to be a valid DateInterval
object, but any attempt to work with the object results in a segfault.

Test script:
---------------
<?php $a = new
DateInterval("2008-05-11T15:30:00Z/2007-03-01T13:00:00Z"); var_dump($a);
?>

Expected result:
----------------
At a minimum, "Not crashing". Ideally, a DateInterval object with a
negative duration, but I don't know of ISO-8601 allows those.

Actual result:
--------------


(gdb) r -r '$a = new
DateInterval("2008-05-11T15:30:00Z/2007-03-01T13:00:00Z");
var_dump($a);'



Program received signal SIGSEGV, Segmentation fault.

0x0000000000420faf in date_object_get_properties_interval (object=<value
optimized out>) at /home/joey/src/php/trunk/ext/date/php_date.c:2242

2242            PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);



"bt full" output available at http://codepad.org/on7ZS6Qd


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52808&edit=1

Reply via email to