From: Antony Dovgal Date: Tue, 11 Jul 2006 14:16:26 +0000 (+0000) Subject: fix segfault in jdmonthname(), add test X-Git-Tag: php-5.2.0RC1~136 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b491930ef63ba3bd369054dd7e9716e16e7dad1a;p=php fix segfault in jdmonthname(), add test --- diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index f48950901a..c9c0bf761b 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -154,6 +154,13 @@ void SdnToGregorian( } temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1; + if (temp < 0) { + *pYear = 0; + *pMonth = 0; + *pDay = 0; + return; + } + /* Calculate the century (year/100). */ century = temp / DAYS_PER_400_YEARS; diff --git a/ext/calendar/tests/jdtomonthname.phpt b/ext/calendar/tests/jdtomonthname.phpt new file mode 100644 index 0000000000..1b5118a96f --- /dev/null +++ b/ext/calendar/tests/jdtomonthname.phpt @@ -0,0 +1,71 @@ +--TEST-- +jdtomonthname() test +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(3) "Jan" +string(7) "January" +string(3) "Jan" +string(7) "January" +string(6) "Shevat" +string(0) "" +string(3) "Jan" +string(7) "January" +string(3) "Dec" +string(8) "December" +string(5) "Tevet" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(6) "AdarII" +string(0) "" +Done