summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-05-12 16:26:26 +0000
committerAntony Dovgal <tony2001@php.net>2005-05-12 16:26:26 +0000
commitcee979d5a9a594c8f1fee5e386bb73298ed30965 (patch)
tree51865dc677581293acdc724740dc5ed4694868b1 /ext/sockets
parentcfa90afcc7a9433628f30dc9842728999d1db1d0 (diff)
downloadphp-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.c9
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);