From 46647bee44bbb7e2709ceeee329c3609295ba068 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli
Date: Wed, 23 Aug 2017 22:50:57 +0800
Subject: [PATCH] fix memory leak
don't leak variable 'space' when the host is numeric
Signed-off-by: Antonio Quartulli
---
src/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/core.c b/src/core.c
index 827ee54..57c1128 100644
--- a/src/core.c
+++ b/src/core.c
@@ -830,7 +830,10 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
if(node && !inet_aton(node, &((struct sockaddr_in *) &space->sockaddr_space)->sin_addr)) {
/* some folks (nmap) use getaddrinfo() with AI_NUMERICHOST to check whether a string
containing a numeric ip was passed. we must return failure in that case. */
- if(hints && (hints->ai_flags & AI_NUMERICHOST)) return EAI_NONAME;
+ if(hints && (hints->ai_flags & AI_NUMERICHOST)) {
+ free(space);
+ return EAI_NONAME;
+ }
hp = proxy_gethostbyname(node, &ghdata);
if(hp)
memcpy(&((struct sockaddr_in *) &space->sockaddr_space)->sin_addr,