Skip to content

Commit a7eda3d

Browse files
committed
Merge branch 'PHP-8.1'
2 parents 22eddb3 + bc43e69 commit a7eda3d

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, bool 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, bool 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 bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
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();
@@ -4535,6 +4553,9 @@ PHP_FUNCTION(date_default_timezone_get)
45354553
ZEND_PARSE_PARAMETERS_NONE();
45364554

45374555
default_tz = get_timezone_info();
4556+
if (!default_tz) {
4557+
return;
4558+
}
45384559
RETVAL_STRING(default_tz->name);
45394560
}
45404561
/* }}} */
@@ -4590,8 +4611,11 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s
45904611
altitude = 90 - zenith;
45914612

45924613
/* Initialize time struct */
4593-
t = timelib_time_ctor();
45944614
tzi = get_timezone_info();
4615+
if (!tzi) {
4616+
return;
4617+
}
4618+
t = timelib_time_ctor();
45954619
t->tz_info = tzi;
45964620
t->zone_type = TIMELIB_ZONETYPE_ID;
45974621

@@ -4661,8 +4685,11 @@ PHP_FUNCTION(date_sun_info)
46614685
ZEND_PARSE_PARAMETERS_END();
46624686

46634687
/* Initialize time struct */
4664-
t = timelib_time_ctor();
46654688
tzi = get_timezone_info();
4689+
if (!tzi) {
4690+
return;
4691+
}
4692+
t = timelib_time_ctor();
46664693
t->tz_info = tzi;
46674694
t->zone_type = TIMELIB_ZONETYPE_ID;
46684695
timelib_unixtime2local(t, time);

0 commit comments

Comments
 (0)