tony2001                Tue Jul 11 14:16:26 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/calendar/tests jdtomonthname.phpt 

  Modified files:              
    /php-src/ext/calendar       gregor.c 
  Log:
  fix segfault in jdmonthname(), add test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/gregor.c?r1=1.2&r2=1.2.26.1&diff_format=u
Index: php-src/ext/calendar/gregor.c
diff -u php-src/ext/calendar/gregor.c:1.2 php-src/ext/calendar/gregor.c:1.2.26.1
--- php-src/ext/calendar/gregor.c:1.2   Sat Feb  2 19:27:33 2002
+++ php-src/ext/calendar/gregor.c       Tue Jul 11 14:16:26 2006
@@ -154,6 +154,13 @@
        }
        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;
 

http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/tests/jdtomonthname.phpt?view=markup&rev=1.1
Index: php-src/ext/calendar/tests/jdtomonthname.phpt
+++ php-src/ext/calendar/tests/jdtomonthname.phpt
--TEST--
jdtomonthname() test
--SKIPIF--
<?php if (!extension_loaded("calendar")) print "skip"; ?>
--FILE--
<?php

$jd_days = Array(
    2453396,
    2440588,
    -1,
    array(),
    1000000000
    );

foreach ($jd_days as $jd_day) {
    var_dump(jdmonthname($jd_day,0));
    var_dump(jdmonthname($jd_day,1));
    var_dump(jdmonthname($jd_day,2));
    var_dump(jdmonthname($jd_day,3));
    var_dump(jdmonthname($jd_day,4));
    var_dump(jdmonthname($jd_day,5));
}

echo "Done\n";

?>
--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

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

Reply via email to