cvs: php-src /ext/standard dl.c /win32 winutil.c
| From: | Marcus Boerger | Date: | Wed, 17 Dec 2003 11:20:36 +0000 |
| Subject: | cvs: php-src /ext/standard dl.c /win32 winutil.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-25249@lists.php.net to get a copy of this message | ||
helly Wed Dec 17 06:20:36 2003 EDT
Modified files:
/php-src/ext/standard dl.c
/php-src/win32 winutil.c
Log:
Fix a memleak: A second call to *nix version of dlerror() frees the error
string. This behavior is also adapted to the win build so that the buffer
returned by FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER) can be freed too.
Index: php-src/ext/standard/dl.c
diff -u php-src/ext/standard/dl.c:1.84 php-src/ext/standard/dl.c:1.85
--- php-src/ext/standard/dl.c:1.84 Sun Aug 17 05:57:21 2003
+++ php-src/ext/standard/dl.c Wed Dec 17 06:20:35 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dl.c,v 1.84 2003/08/17 09:57:21 david Exp $ */
+/* $Id: dl.c,v 1.85 2003/12/17 11:20:35 helly Exp $ */
#include "php.h"
#include "dl.h"
@@ -141,6 +141,7 @@
handle = DL_LOAD(libpath);
if (!handle) {
php_error_docref(NULL TSRMLS_CC, error_type, "Unable to load dynamic library '%s'
- %s", libpath, GET_DL_ERROR());
+ GET_DL_ERROR(); /* free the buffer storing the error */
efree(libpath);
RETURN_FALSE;
}
Index: php-src/win32/winutil.c
diff -u php-src/win32/winutil.c:1.10 php-src/win32/winutil.c:1.11
--- php-src/win32/winutil.c:1.10 Tue Jun 10 16:03:46 2003
+++ php-src/win32/winutil.c Wed Dec 17 06:20:35 2003
@@ -20,8 +20,12 @@
PHPAPI char *php_win_err(int error)
{
- char *buf;
+ static char *buf = NULL;
+ if (buf) {
+ free(buf);
+ buf = NULL;
+ }
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buf, 0, NULL