diff options
author | Chuck Hagenbuch <chagenbu@php.net> | 2001-04-23 21:58:44 +0000 |
---|---|---|
committer | Chuck Hagenbuch <chagenbu@php.net> | 2001-04-23 21:58:44 +0000 |
commit | 029cd8a8829cd856a9d09f91336b017de9b85b4d (patch) | |
tree | f2fbfb9f7b489ebb19a19e3e2925bdd4175633df /ext/imap/php_imap.c | |
parent | 0be5cca176792001bda27cf07861e0716d4f52fe (diff) | |
download | php-git-029cd8a8829cd856a9d09f91336b017de9b85b4d.tar.gz |
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.
Diffstat (limited to 'ext/imap/php_imap.c')
-rw-r--r-- | ext/imap/php_imap.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 7778d6608f..7fb8213b15 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -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); - + if (spg) { + mail_free_searchpgm(&spg); + } + array_init(return_value); - for (sl = slst; *sl; sl++) { - add_next_index_long(return_value, *sl); + 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); } /* }}} */ |