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

diff --git a/NEWS b/NEWS
index a7a43ee30d5a2da4747ce8987caf1f7aa9354697..038c4aa9f12603d37aad93c95e15bc81a1790cef 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ PHP 4                                                                      NEWS
 - Added Oracle Instant Client support. (cjbj at hotmail dot com, Tony)
 - Changed phpize not to require libtool. (Jani)
 - 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 MacOSX shared extensions crashing on Apache startup. (Rasmus)
 - Fixed bug #31858 (--disable-cli does not force --without-pear). (Jani)
index de79ee2033dee3d04b599c3829e0f556b16d8d0e..04084836b1c23694895f15d30df9200b3d7c1a04 100644 (file)
@@ -98,11 +98,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;
 }
 /* }}} */
@@ -145,7 +177,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
 };
 
 
@@ -216,6 +256,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 0f027ae7114ac092d506d40c13f95121a359d9e0..2fb94a94e7aea7a0897d4c803c0149dfabf67481 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