From 44e235dd88d3f506b31db24373c0f5d5fd27c79d Mon Sep 17 00:00:00 2001
From: Lars Ingebrigtsen <larsi@gnus.org>
Date: Fri, 29 Jan 2016 00:36:11 +0100
Subject: [PATCH] Fix memory leak

* process.c (connect_network_socket): Free previous sockaddr
before allocating a new one.
---
 src/process.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/process.c b/src/process.c
index 2f7668a555e..b5d306f7de9 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3005,7 +3005,7 @@ void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
   int xerrno = 0;
   Lisp_Object ip_address;
   int family;
-  struct sockaddr *sa;
+  struct sockaddr *sa = NULL;
   int ret;
   int addrlen;
   struct Lisp_Process *p = XPROCESS (proc);
@@ -3026,6 +3026,8 @@ void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
 #endif
 
       addrlen = get_lisp_to_sockaddr_size (ip_address, &family);
+      if (sa)
+	free (sa);
       sa = alloca (addrlen);
       conv_lisp_to_sockaddr (family, ip_address, sa, addrlen);
 
-- 
2.39.5