Fix for bug 9908: check that the result of mail_sort is not 0 before trying

to dereference the pointer. :)

Also, free sort programs - this might have been a memory leak.
This commit is contained in:
Chuck Hagenbuch 2001-04-23 21:58:44 +00:00
parent 0be5cca176
commit 029cd8a882

View File

@ -2745,12 +2745,17 @@ PHP_FUNCTION(imap_sort)
mypgm->next = NIL;
slst = mail_sort(imap_le_struct->imap_stream, NIL, spg, mypgm, myargc >= 4 ? Z_LVAL_PP(flags) : NIL);
array_init(return_value);
for (sl = slst; *sl; sl++) {
add_next_index_long(return_value, *sl);
if (spg) {
mail_free_searchpgm(&spg);
}
array_init(return_value);
if (slst != NIL && slst != 0) {
for (sl = slst; *sl; sl++) {
add_next_index_long(return_value, *sl);
}
fs_give ((void **) &slst);
}
fs_give ((void **) &slst);
}
/* }}} */
@ -3547,14 +3552,14 @@ PHP_FUNCTION(imap_search)
imap_le_struct = (pils *) zend_list_find(ind, &ind_type);
if (!imap_le_struct || !IS_STREAM(ind_type)) {
php_error(E_WARNING, "Unable to find stream pointer");
efree(search_criteria);
efree(search_criteria);
RETURN_FALSE;
}
IMAPG(imap_messages) = NIL;
mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(search_criteria), flags);
if (IMAPG(imap_messages) == NIL) {
efree(search_criteria);
efree(search_criteria);
RETURN_FALSE;
}
@ -3565,7 +3570,7 @@ PHP_FUNCTION(imap_search)
cur = cur->next;
}
mail_free_messagelist(&IMAPG(imap_messages));
efree(search_criteria);
efree(search_criteria);
}
/* }}} */