diff options
| author | Marcus Boerger <helly@php.net> | 2003-12-17 11:20:35 +0000 |
|---|---|---|
| committer | Marcus Boerger <helly@php.net> | 2003-12-17 11:20:35 +0000 |
| commit | 490fd0eaf272a44cab1885496e94afdb52a8bf66 (patch) | |
| tree | b082c9c887effa7c5543eb7432a42d685a902395 /win32/winutil.c | |
| parent | 094861db8c3d7f655b6fff3ac1eb7aa98b196878 (diff) | |
| download | php-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.
Diffstat (limited to 'win32/winutil.c')
| -rw-r--r-- | win32/winutil.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 |
