From cf500085b4e77c074023f8803e85e764ed2e80fd Mon Sep 17 00:00:00 2001
From: gardners <paul@servalproject.org>
Date: Wed, 2 May 2012 02:32:37 +0930
Subject: [PATCH] fixed file descriptor leak when trying to bind to an
 interface.

---
 overlay_interface.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/overlay_interface.c b/overlay_interface.c
index ddb51d3d..f3c37ed8 100644
--- a/overlay_interface.c
+++ b/overlay_interface.c
@@ -211,6 +211,8 @@ int overlay_interface_init_socket(int interface,struct sockaddr_in src_addr,stru
   if (debug&DEBUG_PACKETRX) fprintf(stderr,"src_addr=%08x\n",(unsigned int)broadcast.sin_addr.s_addr);
   if(bind(I(fd),(struct sockaddr *)&broadcast,sizeof(broadcast))) {
     perror("bind()");
+    close(I(fd));
+    I(fd)=-1;
     return WHY("MP HLR server could not bind to requested UDP port (bind() failed)");
   }
   if (debug&(DEBUG_PACKETRX|DEBUG_IO)) fprintf(stderr,"Bound to port 0x%04x\n",broadcast.sin_port);