Skip to content

Commit bc43e69

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
2 parents 4c0639d + 87f341b commit bc43e69

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

ext/date/php_date.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,9 @@ PHP_FUNCTION(strtotime)
10351035
}
10361036

10371037
tzi = get_timezone_info();
1038+
if (!tzi) {
1039+
return;
1040+
}
10381041

10391042
now = timelib_time_ctor();
10401043
now->tz_info = tzi;
@@ -1094,6 +1097,9 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
10941097
timelib_unixtime2gmt(now, (timelib_sll) php_time());
10951098
} else {
10961099
tzi = get_timezone_info();
1100+
if (!tzi) {
1101+
return;
1102+
}
10971103
now->tz_info = tzi;
10981104
now->zone_type = TIMELIB_ZONETYPE_ID;
10991105
timelib_unixtime2local(now, (timelib_sll) php_time());
@@ -1215,6 +1221,9 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
12151221
timelib_unixtime2gmt(ts, (timelib_sll) timestamp);
12161222
} else {
12171223
tzi = get_timezone_info();
1224+
if (!tzi) {
1225+
return;
1226+
}
12181227
ts->tz_info = tzi;
12191228
ts->zone_type = TIMELIB_ZONETYPE_ID;
12201229
timelib_unixtime2local(ts, (timelib_sll) timestamp);
@@ -1323,6 +1332,9 @@ PHP_FUNCTION(localtime)
13231332
}
13241333

13251334
tzi = get_timezone_info();
1335+
if (!tzi) {
1336+
return;
1337+
}
13261338
ts = timelib_time_ctor();
13271339
ts->tz_info = tzi;
13281340
ts->zone_type = TIMELIB_ZONETYPE_ID;
@@ -1374,6 +1386,9 @@ PHP_FUNCTION(getdate)
13741386
}
13751387

13761388
tzi = get_timezone_info();
1389+
if (!tzi) {
1390+
return;
1391+
}
13771392
ts = timelib_time_ctor();
13781393
ts->tz_info = tzi;
13791394
ts->zone_type = TIMELIB_ZONETYPE_ID;
@@ -2265,6 +2280,9 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size
22652280
tzi = dateobj->time->tz_info;
22662281
} else {
22672282
tzi = get_timezone_info();
2283+
if (!tzi) {
2284+
return 0;
2285+
}
22682286
}
22692287

22702288
now = timelib_time_ctor();
@@ -4536,6 +4554,9 @@ PHP_FUNCTION(date_default_timezone_get)
45364554
ZEND_PARSE_PARAMETERS_NONE();
45374555

45384556
default_tz = get_timezone_info();
4557+
if (!default_tz) {
4558+
return;
4559+
}
45394560
RETVAL_STRING(default_tz->name);
45404561
}
45414562
/* }}} */
@@ -4591,8 +4612,11 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
45914612
altitude = 90 - zenith;
45924613

45934614
/* Initialize time struct */
4594-
t = timelib_time_ctor();
45954615
tzi = get_timezone_info();
4616+
if (!tzi) {
4617+
return;
4618+
}
4619+
t = timelib_time_ctor();
45964620
t->tz_info = tzi;
45974621
t->zone_type = TIMELIB_ZONETYPE_ID;
45984622

@@ -4662,8 +4686,11 @@ PHP_FUNCTION(date_sun_info)
46624686
ZEND_PARSE_PARAMETERS_END();
46634687

46644688
/* Initialize time struct */
4665-
t = timelib_time_ctor();
46664689
tzi = get_timezone_info();
4690+
if (!tzi) {
4691+
return;
4692+
}
4693+
t = timelib_time_ctor();
46674694
t->tz_info = tzi;
46684695
t->zone_type = TIMELIB_ZONETYPE_ID;
46694696
timelib_unixtime2local(t, time);

0 commit comments

Comments
 (0)