summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-12-17 11:20:35 +0000
committerMarcus Boerger <helly@php.net>2003-12-17 11:20:35 +0000
commit490fd0eaf272a44cab1885496e94afdb52a8bf66 (patch)
treeb082c9c887effa7c5543eb7432a42d685a902395
parent094861db8c3d7f655b6fff3ac1eb7aa98b196878 (diff)
downloadphp-git-490fd0eaf272a44cab1885496e94afdb52a8bf66.tar.gz
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.
-rw-r--r--ext/standard/dl.c1
-rw-r--r--win32/winutil.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
index 4d25471192..1b8164e415 100644
--- a/ext/standard/dl.c
+++ b/ext/standard/dl.c
@@ -141,6 +141,7 @@ void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
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;
}
diff --git a/win32/winutil.c b/win32/winutil.c
index 2c3797d168..220fea294c 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -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