Skip to content

Commit 2611b98

Browse files
author
Chuck Hagenbuch
committed
MFH: fix crash bug in imap_sort (php#9908).
1 parent 5b9407d commit 2611b98

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ext/imap/php_imap.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,12 +2748,18 @@ PHP_FUNCTION(imap_sort)
27482748
mypgm->next = NIL;
27492749

27502750
slst = mail_sort(imap_le_struct->imap_stream, NIL, spg, mypgm, myargc >= 4 ? Z_LVAL_PP(flags) : NIL);
2751+
if (spg) {
2752+
mail_free_searchpgm(&spg);
2753+
}
2754+
27512755

27522756
array_init(return_value);
2753-
for (sl = slst; *sl; sl++) {
2754-
add_next_index_long(return_value, *sl);
2757+
if (slst != NIL && slst != 0) {
2758+
for (sl = slst; *sl; sl++) {
2759+
add_next_index_long(return_value, *sl);
2760+
}
2761+
fs_give ((void **) &slst);
27552762
}
2756-
fs_give ((void **) &slst);
27572763
}
27582764
/* }}} */
27592765

0 commit comments

Comments
 (0)