From: Andre Noll Date: Thu, 17 Jan 2008 20:40:38 +0000 (+0100) Subject: net.c: Fix a memory leak in makesock(). X-Git-Tag: v0.3.1~89 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=3c6cd36c4ecfb4a6fb3fba6f04ee761c534fceac;p=paraslash.git net.c: Fix a memory leak in makesock(). "port" was allocated dynamically but never freed. Fix it by using a static buffer instead. This buffer can not overflow as "port_number" is an unsigned short, so its decimal representation consists of at most 5 digits. --- diff --git a/net.c b/net.c index 2db34054..10fc1219 100644 --- a/net.c +++ b/net.c @@ -147,10 +147,11 @@ int makesock(unsigned l3type, unsigned l4type, int passive, { struct addrinfo *local = NULL, *src, *remote = NULL, *dst, hints; - char *port = make_message("%u", port_number); int rc, on = 1, sockfd = -1, socktype = sock_type(l4type); + char port[6]; /* port number has at most 5 digits */ + sprintf(port, "%u", port_number); /* Set up address hint structure */ memset(&hints, 0, sizeof(hints)); hints.ai_family = l3type;