[PATCH 3/3] Add missing va_end() calls

Michele Baldessari michele at acksyn.org
Sat Oct 27 14:38:22 EDT 2012


Add missing va_end() calls on all error paths
---
 lib/socket.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/socket.c b/lib/socket.c
index d53a714..d69bc2f 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -331,13 +331,17 @@ int nl_socket_add_memberships(struct nl_sock *sk, int group, ...)
 	va_start(ap, group);
 
 	while (group != 0) {
-		if (group < 0)
+		if (group < 0) {
+			va_end(ap);
 			return -NLE_INVAL;
+		}
 
 		err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
 						 &group, sizeof(group));
-		if (err < 0)
+		if (err < 0) {
+			va_end(ap);
 			return -nl_syserr2nlerr(errno);
+		}
 
 		group = va_arg(ap, int);
 	}
@@ -375,13 +379,17 @@ int nl_socket_drop_memberships(struct nl_sock *sk, int group, ...)
 	va_start(ap, group);
 
 	while (group != 0) {
-		if (group < 0)
+		if (group < 0) {
+			va_end(ap);
 			return -NLE_INVAL;
+		}
 
 		err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
 						 &group, sizeof(group));
-		if (err < 0)
+		if (err < 0) {
+			va_end(ap);
 			return -nl_syserr2nlerr(errno);
+		}
 
 		group = va_arg(ap, int);
 	}
-- 
1.7.12.1




More information about the libnl mailing list