diff options
author | Zeev Suraski <zeev@php.net> | 2001-05-05 01:42:15 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-05-05 01:42:15 +0000 |
commit | 52ba317606e79e34dd984ab587b71acab28050a7 (patch) | |
tree | 0a3ffbfc3154896b2d1d946170b15631c7b63961 | |
parent | 853bf327707b441c1c4a46b23cf8dc8d6be9130f (diff) | |
download | php-git-52ba317606e79e34dd984ab587b71acab28050a7.tar.gz |
emalloc()'d strings must be freed before the request shutdown;
Rule of the thumb: initialize in RINIT, clean in RSHUTDOWN
-rw-r--r-- | ext/mysql/php_mysql.c | 12 | ||||
-rw-r--r-- | ext/mysql/php_mysql.h | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 2bf457035b..82509151df 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -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; } diff --git a/ext/mysql/php_mysql.h b/ext/mysql/php_mysql.h index 8e3fb71870..aa2213963b 100644 --- a/ext/mysql/php_mysql.h +++ b/ext/mysql/php_mysql.h @@ -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); |