|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-09-09 23:45 UTC] joey@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
Patchesbug52808.patch (last revision 2010-09-10 22:18 UTC by sriram dot natarajan at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 09:00:01 2025 UTC |
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.