From ddf05afe1b1a1e53825a3d2925e4fdb266dff12f Mon Sep 17 00:00:00 2001 From: david Date: Mon, 24 Aug 2009 21:09:47 +0000 Subject: [PATCH] Fix a memory leak in l_nsock_get_info when trying to get information from a closed socket. --- nse_nsock.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nse_nsock.cc b/nse_nsock.cc index 78a97550f..743370a07 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -856,10 +856,6 @@ static int l_nsock_get_info(lua_State * L) struct sockaddr remote; - char *ipstring_local = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN); - - char *ipstring_remote = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN); - if (udata->nsiod == NULL) { lua_pushboolean(L, false); @@ -872,6 +868,9 @@ static int l_nsock_get_info(lua_State * L) lua_pushboolean(L, true); + char *ipstring_local = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN); + char *ipstring_remote = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN); + lua_pushstring(L, inet_ntop_both(af, &local, ipstring_local)); lua_pushnumber(L, inet_port_both(af, &local));