iliaa           Fri Jan 24 12:10:40 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/imap      php_imap.c php_imap.h 
  Log:
  MFH (memory leak in quota functions).
  
  
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.142.2.8 php4/ext/imap/php_imap.c:1.142.2.9
--- php4/ext/imap/php_imap.c:1.142.2.8  Fri Jan 24 05:13:16 2003
+++ php4/ext/imap/php_imap.c    Fri Jan 24 12:10:40 2003
@@ -26,7 +26,7 @@
    | PHP 4.0 updates:  Zeev Suraski <[EMAIL PROTECTED]>                       |
    +----------------------------------------------------------------------+
  */
-/* $Id: php_imap.c,v 1.142.2.8 2003/01/24 10:13:16 sniper Exp $ */
+/* $Id: php_imap.c,v 1.142.2.9 2003/01/24 17:10:40 iliaa Exp $ */
 
 #define IMAP41
 
@@ -339,7 +339,11 @@
 void mail_getquota(MAILSTREAM *stream, char *qroot, QUOTALIST *qlist)
 {
        zval *t_map;
+       zval *return_value;
        TSRMLS_FETCH();
+
+       return_value = *IMAPG(quota_return);
+       
 /* put parsing code here */
        for(; qlist; qlist = qlist->next) {
                MAKE_STD_ZVAL(t_map);
@@ -352,13 +356,13 @@
                if (strncmp(qlist->name, "STORAGE", 7) == 0)
                {
                        /* this is to add backwards compatibility */
-                       add_assoc_long_ex(IMAPG(quota_return), "usage", 
sizeof("usage"), qlist->usage);
-                       add_assoc_long_ex(IMAPG(quota_return), "limit", 
sizeof("limit"), qlist->limit);
+                       add_assoc_long_ex(return_value, "usage", sizeof("usage"), 
+qlist->usage);
+                       add_assoc_long_ex(return_value, "limit", sizeof("limit"), 
+qlist->limit);
                }
 
                add_assoc_long_ex(t_map, "usage", sizeof("usage"), qlist->usage);
                add_assoc_long_ex(t_map, "limit", sizeof("limit"), qlist->limit);
-               add_assoc_zval_ex(IMAPG(quota_return), qlist->name, 
strlen(qlist->name)+1, t_map);
+               add_assoc_zval_ex(return_value, qlist->name, strlen(qlist->name)+1, 
+t_map);
        }
 }
 /* }}} */
@@ -862,22 +866,16 @@
 
        convert_to_string_ex(qroot);
 
-       MAKE_STD_ZVAL(IMAPG(quota_return));
-       if (array_init(IMAPG(quota_return)) == FAILURE) {
-               php_error(E_WARNING, "%s(): Unable to allocate array memory", 
get_active_function_name(TSRMLS_C));
-               FREE_ZVAL(IMAPG(quota_return));
-               RETURN_FALSE;
-       }
+       array_init(return_value);
+       IMAPG(quota_return) = &return_value;
 
        /* set the callback for the GET_QUOTA function */
        mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);
        if(!imap_getquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot))) {
-               php_error(E_WARNING, "%s(): c-client imap_getquota failed", 
get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client imap_getquota 
+failed");
+               zval_dtor(return_value);
                RETURN_FALSE;
        }
-
-       *return_value = *IMAPG(quota_return);
-       FREE_ZVAL(IMAPG(quota_return));
 }
 /* }}} */
 
@@ -896,22 +894,16 @@
 
        convert_to_string_ex(mbox);
 
-       MAKE_STD_ZVAL(IMAPG(quota_return));
-       if (array_init(IMAPG(quota_return)) == FAILURE) {
-               php_error(E_WARNING, "%s(): Unable to allocate array memory", 
get_active_function_name(TSRMLS_C));
-               FREE_ZVAL(IMAPG(quota_return));
-               RETURN_FALSE;
-       }
+       array_init(return_value);
+       IMAPG(quota_return) = &return_value;
 
        /* set the callback for the GET_QUOTAROOT function */
        mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);
        if(!imap_getquotaroot(imap_le_struct->imap_stream, Z_STRVAL_PP(mbox))) {
-               php_error(E_WARNING, "%s(): c-client imap_getquotaroot failed", 
get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client 
+imap_getquotaroot failed");
+               zval_dtor(return_value);
                RETURN_FALSE;
        }
-
-       *return_value = *IMAPG(quota_return);
-       FREE_ZVAL(IMAPG(quota_return));
 }
 /* }}} */
 
Index: php4/ext/imap/php_imap.h
diff -u php4/ext/imap/php_imap.h:1.24.2.1 php4/ext/imap/php_imap.h:1.24.2.2
--- php4/ext/imap/php_imap.h:1.24.2.1   Tue Dec 31 11:34:44 2002
+++ php4/ext/imap/php_imap.h    Fri Jan 24 12:10:40 2003
@@ -27,7 +27,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_imap.h,v 1.24.2.1 2002/12/31 16:34:44 sebastian Exp $ */
+/* $Id: php_imap.h,v 1.24.2.2 2003/01/24 17:10:40 iliaa Exp $ */
 
 #ifndef PHP_IMAP_H
 #define PHP_IMAP_H
@@ -200,7 +200,7 @@
        unsigned long status_uidnext;
        unsigned long status_uidvalidity;
 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
-       zval *quota_return;
+       zval **quota_return;
 #endif
 ZEND_END_MODULE_GLOBALS(imap)
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to