Skip to content

Commit b58dc6f

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-13680: Segfault with session_decode and compilation error
2 parents 1b5d9f6 + 6985aff commit b58dc6f

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ PHP NEWS
3030
. Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with unknown
3131
modes). (timwolla)
3232

33+
- Session:
34+
. Fixed bug GH-13680 (Segfault with session_decode and compilation error).
35+
(nielsdos)
36+
3337
- Standard:
3438
. Fixed bug GH-11808 (Live filesystem modified by tests). (nielsdos)
3539
. Fixed GH-13402 (Added validation of `\n` in $additional_headers of mail()).

ext/session/session.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,17 @@ static zend_result php_session_decode(zend_string *data) /* {{{ */
271271
php_error_docref(NULL, E_WARNING, "Unknown session.serialize_handler. Failed to decode session object");
272272
return FAILURE;
273273
}
274+
zend_result result = SUCCESS;
274275
zend_try {
275276
if (PS(serializer)->decode(ZSTR_VAL(data), ZSTR_LEN(data)) == FAILURE) {
276277
php_session_cancel_decode();
277-
return FAILURE;
278+
result = FAILURE;
278279
}
279280
} zend_catch {
280281
php_session_cancel_decode();
281282
zend_bailout();
282283
} zend_end_try();
283-
return SUCCESS;
284+
return result;
284285
}
285286
/* }}} */
286287

ext/session/tests/gh13680.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-13680 (Segfault with session_decode and compilation error)
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--INI--
8+
session.use_cookies=0
9+
session.use_strict_mode=0
10+
session.cache_limiter=
11+
session.serialize_handler=php_serialize
12+
session.save_handler=files
13+
error_reporting=E_ALL
14+
--FILE--
15+
<?php
16+
session_start();
17+
session_decode('foo');
18+
class Test extends DateTime {
19+
public static function createFromFormat($format, $datetime, $timezone = null): Wrong {}
20+
}
21+
?>
22+
--EXPECTF--
23+
Warning: session_decode(): Failed to decode session object. Session has been destroyed in %s on line %d
24+
25+
Fatal error: Could not check compatibility between Test::createFromFormat($format, $datetime, $timezone = null): Wrong and DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false, because class Wrong is not available in %s on line %d

0 commit comments

Comments
 (0)