summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-10-13 19:40:49 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-10-13 19:41:27 +0200
commit5aec24c477e72e71a846361f93ef8861b7a262e5 (patch)
treeda145346c56b1b4ece8f7715090d411f2cdd13a2
parent9b4094c3d74cb7e71dd2dc6ae6673a17575b2a13 (diff)
parentd9058b61fb3e1ef0697433324716a8843e92c115 (diff)
downloadphp-git-5aec24c477e72e71a846361f93ef8861b7a262e5.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #64076: imap_sort() does not return FALSE on failure
-rw-r--r--NEWS1
-rw-r--r--ext/imap/php_imap.c3
-rw-r--r--ext/imap/tests/bug64076.phpt23
3 files changed, 27 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 883ec6e120..c5714fa2a1 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PHP NEWS
. Fixed bug #80216 (imap_mail_compose() does not validate types/encodings).
(cmb)
. Fixed bug #80226 (imap_sort() leaks sortpgm memory). (cmb)
+ . Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
- Opcache:
. Fixed bug #80184 (Complex expression in while / if statements resolves to
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 7c8768fbfb..a4d636849c 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -2740,6 +2740,9 @@ PHP_FUNCTION(imap_sort)
} else {
spg = mail_newsearchpgm();
}
+ if (spg == NIL) {
+ RETURN_FALSE;
+ }
mypgm = mail_newsortpgm();
mypgm->reverse = rev;
diff --git a/ext/imap/tests/bug64076.phpt b/ext/imap/tests/bug64076.phpt
new file mode 100644
index 0000000000..ccafcfe251
--- /dev/null
+++ b/ext/imap/tests/bug64076.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #64076 (imap_sort() does not return FALSE on failure)
+--SKIPIF--
+<?php
+require_once __DIR__ . '/skipif.inc';
+?>
+--FILE--
+<?php
+require_once __DIR__ . '/imap_include.inc';
+$stream = setup_test_mailbox('', 2);
+imap_errors(); // clear error stack
+var_dump(imap_sort($stream, SORTFROM, 0, 0, 'UNSUPPORTED SEARCH CRITERIUM'));
+var_dump(imap_errors() !== false);
+?>
+--CLEAN--
+<?php
+require_once __DIR__ . '/clean.inc';
+?>
+--EXPECT--
+Create a temporary mailbox and add 2 msgs
+.. mailbox '{127.0.0.1:143/norsh}INBOX.phpttest' created
+bool(false)
+bool(true)