mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Fixed bug in SdnToGregorian (see comments on #53574, though that bug is about
another function). NEWS & tests tomorrow.
This commit is contained in:
parent
5ad03cd41a
commit
43f215a463
1 changed files with 9 additions and 9 deletions
|
@ -127,6 +127,7 @@
|
|||
**************************************************************************/
|
||||
|
||||
#include "sdncal.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define GREGOR_SDN_OFFSET 32045
|
||||
#define DAYS_PER_5_MONTHS 153
|
||||
|
@ -146,19 +147,14 @@ void SdnToGregorian(
|
|||
long int temp;
|
||||
int dayOfYear;
|
||||
|
||||
if (sdn <= 0) {
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
return;
|
||||
if (sdn <= 0 ||
|
||||
sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
|
||||
goto fail;
|
||||
}
|
||||
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
|
||||
|
||||
if (temp < 0) {
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
return;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Calculate the century (year/100). */
|
||||
|
@ -190,6 +186,10 @@ void SdnToGregorian(
|
|||
*pYear = year;
|
||||
*pMonth = month;
|
||||
*pDay = day;
|
||||
fail:
|
||||
*pYear = 0;
|
||||
*pMonth = 0;
|
||||
*pDay = 0;
|
||||
}
|
||||
|
||||
long int GregorianToSdn(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue