mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-9155: dba_open("non-existing", "c-", "flatfile") segfaults
This commit is contained in:
commit
89216b23dd
@ -824,11 +824,10 @@ restart:
|
||||
fcntl(info->fd, F_SETFL, flags & ~O_APPEND);
|
||||
#elif defined(PHP_WIN32)
|
||||
} else if (modenr == DBA_CREAT && need_creation && !restarted) {
|
||||
bool close_both;
|
||||
|
||||
close_both = (info->fp != info->lock.fp);
|
||||
php_stream_free(info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
|
||||
if (close_both) {
|
||||
if (info->lock.fp != NULL) {
|
||||
php_stream_free(info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
if (info->fp != info->lock.fp) {
|
||||
php_stream_free(info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE);
|
||||
}
|
||||
info->fp = NULL;
|
||||
|
23
ext/dba/tests/gh9155.phpt
Normal file
23
ext/dba/tests/gh9155.phpt
Normal file
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug GH-9155 (dba_open("non-existing", "c-", "flatfile") segfaults)
|
||||
--EXTENSIONS--
|
||||
dba
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = "flatfile";
|
||||
require_once(__DIR__ .'/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ .'/test.inc');
|
||||
|
||||
$db = dba_open($db_filename, 'c-', 'flatfile');
|
||||
var_dump($db);
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once(__DIR__ .'/clean.inc');
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (dba)
|
Loading…
Reference in New Issue
Block a user