File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
tests/user_session_module Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ PHP NEWS
6464 . Fixed bug GH-21731 (Random\Engine\Xoshiro256StarStar::__unserialize()
6565 accepts all-zero state). (iliaal)
6666
67+ - Session:
68+ . Fixed memory leak when session GC callback return a refcounted value.
69+ (jorgsowa)
70+
6771- SPL:
6872 . Fixed bug GH-21499 (RecursiveArrayIterator getChildren UAF after parent
6973 free). (Girgias)
Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ PS_GC_FUNC(user)
218218 /* Anything else is some kind of error */
219219 * nrdels = -1 ; // Error
220220 }
221+ zval_ptr_dtor (& retval );
221222 return * nrdels ;
222223}
223224
Original file line number Diff line number Diff line change 1+ --TEST--
2+ session_gc(): user handler returning non-bool/non-int does not leak memory
3+ --INI--
4+ session.gc_probability=0
5+ session.save_handler=files
6+ --EXTENSIONS--
7+ session
8+ --FILE--
9+ <?php
10+ ob_start ();
11+
12+ // Procedural API has no return type enforcement, so gc can return a string
13+ // (reference-counted), which PS_GC_FUNC(user) previously did not free.
14+ session_set_save_handler (
15+ function (string $ path , string $ name ) { return true ; },
16+ function () { return true ; },
17+ function (string $ id ): string |false { return "" ; },
18+ function (string $ id , string $ data ) { return true ; },
19+ function (string $ id ) { return true ; },
20+ function (int $ max ) { return str_repeat ("x " , random_int (100 , 100 )); }
21+ );
22+
23+ session_start ();
24+ $ result = session_gc ();
25+ var_dump ($ result );
26+ session_write_close ();
27+
28+ ob_end_flush ();
29+ ?>
30+ --EXPECTF--
31+
32+ Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
33+ bool(false)
You can’t perform that action at this time.
0 commit comments