dovecot-2.2: lib: pair VA_COPY with va_end

dovecot at dovecot.org dovecot at dovecot.org
Tue May 27 18:19:09 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/03870eea2857
changeset: 17396:03870eea2857
user:      Phil Carmody <phil at dovecot.fi>
date:      Tue May 27 21:17:34 2014 +0300
description:
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 at dovecot.fi>

diffstat:

 src/lib/str.c      |  1 +
 src/lib/strfuncs.c |  1 +
 src/master/main.c  |  3 +++
 3 files changed, 5 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r ad028a950248 -r 03870eea2857 src/lib/str.c
--- 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);
diff -r ad028a950248 -r 03870eea2857 src/lib/strfuncs.c
--- 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;
 }
 
diff -r ad028a950248 -r 03870eea2857 src/master/main.c
--- 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);
 }
 


More information about the dovecot-cvs mailing list