thekid          Sat Dec  7 14:49:31 2002 EDT

  Modified files:              
    /php4/ext/sybase_ct php_sybase_ct.c 
  Log:
  - Fixed three memory leaks
  - Fixed segfault with sybase_unbuffered_query() and unfetched resultsets 
  
  
Index: php4/ext/sybase_ct/php_sybase_ct.c
diff -u php4/ext/sybase_ct/php_sybase_ct.c:1.73 php4/ext/sybase_ct/php_sybase_ct.c:1.74
--- php4/ext/sybase_ct/php_sybase_ct.c:1.73     Tue Nov 12 17:59:11 2002
+++ php4/ext/sybase_ct/php_sybase_ct.c  Sat Dec  7 14:49:31 2002
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_sybase_ct.c,v 1.73 2002/11/12 22:59:11 edink Exp $ */
+/* $Id: php_sybase_ct.c,v 1.74 2002/12/07 19:49:31 thekid Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -408,7 +408,7 @@
 {
        efree(SybCtG(appname));
        if (SybCtG(callback_name)) {
-               zval_dtor(SybCtG(callback_name));
+               zval_ptr_dtor(&SybCtG(callback_name));
                SybCtG(callback_name)= NULL;
        }
        STR_FREE(SybCtG(server_message));
@@ -1261,7 +1261,7 @@
        
        /* Check to see if a previous sybase_unbuffered_query has read all rows */
        if (sybase_ptr->active_result_index) {
-               zval *tmp;
+               zval *tmp = NULL;
                
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Sybase:  Called %s() 
without first fetching all rows from a previous unbuffered query",
                        get_active_function_name(TSRMLS_C));
@@ -1275,10 +1275,20 @@
                Z_TYPE_P(tmp)= IS_RESOURCE;
                INIT_PZVAL(tmp);
                ZEND_FETCH_RESOURCE(result, sybase_result *, &tmp, -1, "Sybase 
result", le_result);
+               
+               /* Causes the following segfault:
+                  Program received signal SIGSEGV, Segmentation fault.
+                  0x8144380 in _efree (ptr=0x81fe024, __zend_filename=0x81841a0 
+"php4/ext/sybase_ct/php_sybase_ct.c", 
+                  __zend_lineno=946, __zend_orig_filename=0x0, __zend_orig_lineno=0) 
+at php4/Zend/zend_alloc.c:229
+                  php4/Zend/zend_alloc.c:229:7284:beg:0x8144380
+               */
+               #if O_TIMM
                if (result) {
                        php_sybase_finish_results(result);
                }
-               zval_dtor(tmp);
+               #endif
+               
+               zval_ptr_dtor(&tmp);
                zend_list_delete(sybase_ptr->active_result_index);
                sybase_ptr->active_result_index= 0;
        }
@@ -1630,8 +1640,8 @@
                }
                if (numerics) {
                        zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) 
&tmp, sizeof(zval *), NULL);
+                       tmp->refcount++;
                }
-               tmp->refcount++;
                
                if (zend_hash_exists(Z_ARRVAL_P(return_value), result->fields[i].name, 
strlen(result->fields[i].name)+1)) {
                        snprintf(name, 32, "%s%d", result->fields[i].name, j);
@@ -2057,8 +2067,6 @@
                efree(params);
                RETURN_FALSE;
        }
-       
-       MAKE_STD_ZVAL(SybCtG(callback_name));
        
        ALLOC_ZVAL(SybCtG(callback_name));
        *SybCtG(callback_name) = **params[0];



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

Reply via email to