[rpld,6/6] send: ensure we free the buffer after sending the message
diff mbox series

Message ID 20190918195819.7492-7-stefan@datenfreihafen.org
State Not Applicable
Headers show
Series
  • Mixed bag of rpld patches
Related show

Commit Message

Stefan Schmidt Sept. 18, 2019, 7:58 p.m. UTC
We have been leaking all buffers for every send so far.

Fixes Coverity IDs 250810, 250807, 250806, 250805
---
 send.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/send.c b/send.c
index d026f6a..50f73da 100644
--- a/send.c
+++ b/send.c
@@ -29,9 +29,10 @@ 
 
 static int really_send(int sock, const struct iface *iface,
 		       const struct in6_addr *dest,
-		       const struct safe_buffer *sb)
+		       struct safe_buffer *sb)
 {
 	struct sockaddr_in6 addr;
+	int rc;
 	memset((void *)&addr, 0, sizeof(addr));
 	addr.sin6_family = AF_INET6;
 	addr.sin6_port = htons(IPPROTO_ICMPV6);
@@ -67,7 +68,10 @@  static int really_send(int sock, const struct iface *iface,
 	mhdr.msg_control = (void *)cmsg;
 	mhdr.msg_controllen = sizeof(chdr);
 
-	return sendmsg(sock, &mhdr, 0);
+	rc = sendmsg(sock, &mhdr, 0);
+	safe_buffer_free(sb);
+
+	return rc;
 }
 void send_dio(int sock, struct dag *dag)
 {