chagenbu                Mon Apr 23 14:58:44 2001 EDT

  Modified files:              
    /php4/ext/imap      php_imap.c 
  Log:
  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.
  
  
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.64 php4/ext/imap/php_imap.c:1.65
--- php4/ext/imap/php_imap.c:1.64       Sat Apr  7 18:13:07 2001
+++ php4/ext/imap/php_imap.c    Mon Apr 23 14:58:44 2001
@@ -25,7 +25,7 @@
    | PHP 4.0 updates:  Zeev Suraski <[EMAIL PROTECTED]>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_imap.c,v 1.64 2001/04/08 01:13:07 jon Exp $ */
+/* $Id: php_imap.c,v 1.65 2001/04/23 21:58:44 chagenbu Exp $ */
 
 #define IMAP41
 
@@ -2745,12 +2745,17 @@
        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 @@
        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 @@
                cur = cur->next;
        }
        mail_free_messagelist(&IMAPG(imap_messages));
-    efree(search_criteria);
+       efree(search_criteria);
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to