mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix GH-9309: Segfault when connection is used after imap_close()
We actually need to check whether `php_imap_object.imap_stream` is `NULL` to detect that the connection has already been closed. Closes GH-9313.
This commit is contained in:
parent
7908aae30c
commit
71c22efae7
3 changed files with 33 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -22,6 +22,10 @@ PHP NEWS
|
|||
. Fixed bug GH-9155 (dba_open("non-existing", "c-", "flatfile") segfaults)
|
||||
(cmb)
|
||||
|
||||
- IMAP:
|
||||
. Fixed bug GH-9309 (Segfault when connection is used after imap_close()).
|
||||
(cmb)
|
||||
|
||||
- MBString:
|
||||
. Fixed bug GH-9008 (mb_detect_encoding(): wrong results with null $encodings).
|
||||
(cmb)
|
||||
|
|
|
@ -198,7 +198,7 @@ static void imap_object_destroy(zend_object *zobj) {
|
|||
|
||||
#define GET_IMAP_STREAM(imap_conn_struct, zval_imap_obj) \
|
||||
imap_conn_struct = imap_object_from_zend_object(Z_OBJ_P(zval_imap_obj)); \
|
||||
if (!imap_conn_struct) { \
|
||||
if (imap_conn_struct->imap_stream == NULL) { \
|
||||
zend_throw_exception(zend_ce_value_error, "IMAP\\Connection is already closed", 0); \
|
||||
RETURN_THROWS(); \
|
||||
}
|
||||
|
|
28
ext/imap/tests/gh9309.phpt
Normal file
28
ext/imap/tests/gh9309.phpt
Normal file
|
@ -0,0 +1,28 @@
|
|||
--TEST--
|
||||
Bug GH-9309 (Segfault when connection is used after imap_close())
|
||||
--EXTENSIONS--
|
||||
imap
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__.'/setup/skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__.'/setup/imap_include.inc');
|
||||
$stream_id = setup_test_mailbox('gh9309', 0, $mailbox);
|
||||
imap_close($stream_id);
|
||||
try {
|
||||
imap_headers($stream_id);
|
||||
} catch (ValueError $ex) {
|
||||
echo $ex->getMessage(), PHP_EOL;
|
||||
}
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$mailbox_suffix = 'gh9309';
|
||||
require_once(__DIR__.'/setup/clean.inc');
|
||||
?>
|
||||
--EXPECT--
|
||||
Create a temporary mailbox and add 0 msgs
|
||||
New mailbox created
|
||||
IMAP\Connection is already closed
|
Loading…
Add table
Add a link
Reference in a new issue