diff options
author | Antony Dovgal <tony2001@php.net> | 2005-05-12 16:26:26 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2005-05-12 16:26:26 +0000 |
commit | cee979d5a9a594c8f1fee5e386bb73298ed30965 (patch) | |
tree | 51865dc677581293acdc724740dc5ed4694868b1 /ext/sockets | |
parent | cfa90afcc7a9433628f30dc9842728999d1db1d0 (diff) | |
download | php-git-cee979d5a9a594c8f1fee5e386bb73298ed30965.tar.gz |
fix #33019 (socket errors cause memory leaks in php_strerror())
patch by jwozniak23 at poczta dot onet dot pl
Diffstat (limited to 'ext/sockets')
-rw-r--r-- | ext/sockets/sockets.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 8c2486e6ea..b45da19b8a 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -321,6 +321,10 @@ static char *php_strerror(int error TSRMLS_DC) buf = hstrerror(error); #else { + if (SOCKETS_G(strerror_buf)) { + efree(SOCKETS_G(strerror_buf)); + } + spprintf(&(SOCKETS_G(strerror_buf)), 0, "Host lookup error %d", error); buf = SOCKETS_G(strerror_buf); } @@ -335,6 +339,11 @@ static char *php_strerror(int error TSRMLS_DC) if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &tmp, 0, NULL)) { + + if (SOCKETS_G(strerror_buf)) { + efree(SOCKETS_G(strerror_buf)); + } + SOCKETS_G(strerror_buf) = estrdup(tmp); LocalFree(tmp); |