]> granicus.if.org Git - php/commitdiff
MFH: fix leaks in ext/filepro
authorAntony Dovgal <tony2001@php.net>
Mon, 7 Feb 2005 13:31:42 +0000 (13:31 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 7 Feb 2005 13:31:42 +0000 (13:31 +0000)
NEWS
ext/filepro/filepro.c
ext/filepro/php_filepro.h

diff --git a/NEWS b/NEWS
index 556e23a3b1294ec58ef940c1cc47354b2fc81d48..ec2acb826ad7f52dc541e8567724f15c5d2d3b0f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PHP                                                                        NEWS
 - Fixed a bug in mysql_affected_rows and mysql_stmt_affected_rows when the
   api function returns -1 (Georg)
 - Fixed several egregious leaks in ext/browscap and sapi/embed. (Andrei)
+- Fixed several leaks in ext/filepro. (Tony)
 - Fixed build system to always use bundled libtool files. (Jani)
 - Fixed a bug in mysqli_stmt_execute() (type conversion with NULL values). (Georg)
 - Fixed segfault in mysqli_fetch_field_direct() when invalid field offset 
index 2821c9aa163d9b7d7cbd04670b8db885e1ea18c8..737a1e0c0dfa1274e1dd3ebb81f29354164030dd 100644 (file)
@@ -96,11 +96,43 @@ PHP_MINIT_FUNCTION(filepro)
        fp_globals = (fp_global_struct *) LocalAlloc(LPTR, sizeof(fp_global_struct)); 
        TlsSetValue(FPTls, (void *) fp_globals);
 #endif
+
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(filepro)
+{
        FP_GLOBAL(fp_database)=NULL;
        FP_GLOBAL(fp_fcount)=-1;
        FP_GLOBAL(fp_keysize)=-1;
        FP_GLOBAL(fp_fieldlist)=NULL;
+       return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+PHP_RSHUTDOWN_FUNCTION(filepro)
+{
+       FP_FIELD *tmp, *next;
 
+       if (FP_GLOBAL(fp_database)) {
+               efree(FP_GLOBAL(fp_database));
+       }
+       
+       if (FP_GLOBAL(fp_fieldlist)) {
+               for (tmp = FP_GLOBAL(fp_fieldlist); tmp;) {
+                       efree(tmp->name);
+                       efree(tmp->format);
+                       next = tmp->next;
+                       efree(tmp);
+                       tmp=next;
+               }       
+       }
        return SUCCESS;
 }
 /* }}} */
@@ -143,7 +175,15 @@ function_entry filepro_functions[] = {
 
 zend_module_entry filepro_module_entry = {
        STANDARD_MODULE_HEADER,
-       "filepro", filepro_functions, PHP_MINIT(filepro), PHP_MSHUTDOWN(filepro), NULL, NULL, NULL, NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
+       "filepro", 
+       filepro_functions, 
+       PHP_MINIT(filepro), 
+       PHP_MSHUTDOWN(filepro), 
+       PHP_RINIT(filepro), 
+       PHP_RSHUTDOWN(filepro), 
+       NULL, 
+       NO_VERSION_YET, 
+       STANDARD_MODULE_PROPERTIES
 };
 
 
@@ -214,6 +254,8 @@ PHP_FUNCTION(filepro)
        tmp = FP_GLOBAL(fp_fieldlist);
        while (tmp != NULL) {
                next = tmp->next;
+               efree(tmp->name);
+               efree(tmp->format);
                efree(tmp);
                tmp = next;
        } 
index 31a72c4641612a0b78847eb0153a550d99b8e79f..85ff69b605a2ad26be4623b3e740c0bbbcbe2552 100644 (file)
@@ -41,6 +41,8 @@ PHP_FUNCTION(filepro_fieldcount);
 PHP_FUNCTION(filepro_retrieve);
 
 PHP_MINIT_FUNCTION(filepro);
+PHP_RINIT_FUNCTION(filepro);
+PHP_RSHUTDOWN_FUNCTION(filepro);
 PHP_MSHUTDOWN_FUNCTION(filepro);
 #else
 #define phpext_filepro_ptr NULL