[PATCH rpld 6/6] send: ensure we free the buffer after sending the message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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(-)

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)
 {
-- 
2.21.0




[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux