]> granicus.if.org Git - php/commitdiff
emalloc()'d strings must be freed before the request shutdown;
authorZeev Suraski <zeev@php.net>
Sat, 5 May 2001 01:42:15 +0000 (01:42 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 5 May 2001 01:42:15 +0000 (01:42 +0000)
Rule of the thumb:  initialize in RINIT, clean in RSHUTDOWN

ext/mysql/php_mysql.c
ext/mysql/php_mysql.h

index 2bf457035b0009ee6e17f7f3c219cc60e156cdca..82509151df8d2c8e711f1af1029b8f30bb91e492 100644 (file)
@@ -173,7 +173,7 @@ function_entry mysql_functions[] = {
 };
 
 zend_module_entry mysql_module_entry = {
-       "mysql", mysql_functions, PHP_MINIT(mysql), PHP_MSHUTDOWN(mysql), PHP_RINIT(mysql), NULL
+       "mysql", mysql_functions, PHP_MINIT(mysql), PHP_MSHUTDOWN(mysql), PHP_RINIT(mysql), PHP_RSHUTDOWN(mysql)
                         PHP_MINFO(mysql), STANDARD_MODULE_PROPERTIES
 };
 
@@ -323,11 +323,17 @@ PHP_RINIT_FUNCTION(mysql)
        MySG(default_link)=-1;
        MySG(num_links) = MySG(num_persistent);
        /* Reset connect error/errno on every request */
+       MySG(connect_error) = NULL;
+       MySG(connect_errno)=0;
+       return SUCCESS;
+}
+
+
+PHP_RSHUTDOWN_FUNCTION(mysql)
+{
        if (MySG(connect_error)!=NULL) {
                efree(MySG(connect_error));
-               MySG(connect_error)=NULL;
        }
-       MySG(connect_errno)=0;
        return SUCCESS;
 }
 
index 8e3fb71870af9c40fd281664c6f1af175cbcd64a..aa2213963b2a320bba04bedccd8c4e8deb8bbd19 100644 (file)
@@ -41,6 +41,7 @@ extern zend_module_entry mysql_module_entry;
 extern PHP_MINIT_FUNCTION(mysql);
 extern PHP_RINIT_FUNCTION(mysql);
 extern PHP_MSHUTDOWN_FUNCTION(mysql);
+extern PHP_RSHUTDOWN_FUNCTION(mysql);
 PHP_MINFO_FUNCTION(mysql);
 
 PHP_FUNCTION(mysql_connect);