changeset 17396:03870eea2857

lib: pair VA_COPY with va_end A va_copy creates a initialised va_list, as if a va_start had been done on it. Therefore, pedantically, a va_end should also be done on it. On most platforms this is a no-op, and for those where it isn't, the pairing is important. Signed-off-by: Phil Carmody <phil@dovecot.fi>
author Phil Carmody <phil@dovecot.fi>
date Tue, 27 May 2014 21:17:34 +0300
parents ad028a950248
children f373df52082a
files src/lib/str.c src/lib/strfuncs.c src/master/main.c
diffstat 3 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/str.c	Tue May 27 21:17:34 2014 +0300
+++ b/src/lib/str.c	Tue May 27 21:17:34 2014 +0300
@@ -170,6 +170,7 @@
 		ret2 = vsnprintf(tmp, ret + 1, fmt, args2);
 		i_assert(ret2 == ret);
 	}
+	va_end(args2);
 
 	/* drop the unused data, including terminating NUL */
 	buffer_set_used_size(str, pos + ret);
--- a/src/lib/strfuncs.c	Tue May 27 21:17:34 2014 +0300
+++ b/src/lib/strfuncs.c	Tue May 27 21:17:34 2014 +0300
@@ -134,6 +134,7 @@
 	/* we rely on errno not changing. it shouldn't. */
 	i_assert(errno == old_errno);
 #endif
+	va_end(args2);
 	return tmp;
 }
 
--- a/src/master/main.c	Tue May 27 21:17:34 2014 +0300
+++ b/src/master/main.c	Tue May 27 21:17:34 2014 +0300
@@ -156,6 +156,7 @@
 		if (fd != -1) {
 			VA_COPY(args2, args);
 			str = t_strdup_vprintf(format, args2);
+			va_end(args2);
 			(void)write_full(fd, str, strlen(str));
 			i_close_fd(&fd);
 		}
@@ -174,6 +175,7 @@
 	VA_COPY(args2, args);
 	fprintf(stderr, "%s%s\n", failure_log_type_prefixes[ctx->type],
 		t_strdup_vprintf(fmt, args2));
+	va_end(args2);
 	orig_fatal_callback(ctx, fmt, args);
 	abort();
 }
@@ -187,6 +189,7 @@
 	VA_COPY(args2, args);
 	fprintf(stderr, "%s%s\n", failure_log_type_prefixes[ctx->type],
 		t_strdup_vprintf(fmt, args2));
+	va_end(args2);
 	orig_error_callback(ctx, fmt, args);
 }