Skip to content

Commit b37bbf6

Browse files
committed
ext/session: Fix memory leak
1 parent defc0be commit b37bbf6

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

ext/session/mod_files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ PS_CLOSE_FUNC(files)
451451

452452
zend_string_release_ex(data->basedir, /* persistent */ false);
453453
efree(data);
454-
PS_SET_MOD_DATA(NULL);
454+
PS_SET_MOD_DATA(data);
455455

456456
return SUCCESS;
457457
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
SessionHandler::validateId must return bool
3+
--INI--
4+
session.use_strict_mode=1
5+
--EXTENSIONS--
6+
session
7+
--SKIPIF--
8+
<?php include('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
class MySession extends SessionHandler {
12+
public function validateId($key) {
13+
return null;
14+
}
15+
}
16+
17+
$handler = new MySession();
18+
19+
try {
20+
session_set_save_handler($handler);
21+
session_start();
22+
} catch (TypeError $e) {
23+
echo $e->getMessage(), "\n";
24+
}
25+
26+
session_write_close();
27+
28+
try {
29+
session_start();
30+
} catch (Throwable $e) {
31+
echo $e->getMessage(), "\n";
32+
}
33+
?>
34+
--EXPECTF--
35+
Session id must be a string

0 commit comments

Comments
 (0)