]> granicus.if.org Git - libevent/commitdiff
r15249@tombo: nickm | 2008-04-18 09:46:02 -0400
authorNick Mathewson <nickm@torproject.org>
Fri, 18 Apr 2008 13:46:13 +0000 (13:46 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 18 Apr 2008 13:46:13 +0000 (13:46 +0000)
 Avoid leaking a string in the unlikely OOM case from name_from_addr. spotted by niels.

svn:r724

http.c

diff --git a/http.c b/http.c
index efd9f7b7c49c729832dd37fa7ac622b93fc537fb..b9f33882c45efada9652ec870d30acd68f0b2f26 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2275,8 +2275,11 @@ evhttp_get_request_connection(
        char *hostname = NULL, *portname = NULL;
 
        name_from_addr(sa, salen, &hostname, &portname);
-        if (hostname==NULL || portname==NULL)
+       if (hostname==NULL || portname==NULL) {
+               if (hostname) event_free(hostname);
+               if (portname) event_free(portname);
                return (NULL);
+       }
 
        event_debug(("%s: new request from %s:%s on %d\n",
                        __func__, hostname, portname, fd));