From 7f7a0c023fa83fcb7443bdee523464d4673de40c Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Fri, 24 Apr 2009 12:36:58 +0200 Subject: Fix a nasty va_list bug. We were using the same va_list twice, which caused a nasty segfault inside the C library. --- src/str.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/str.c b/src/str.c index f5908c9..5fb8a89 100644 --- a/src/str.c +++ b/src/str.c @@ -410,18 +410,23 @@ str_vsprintf(ld_string_t *dest, const char *format, va_list ap) { int len; isc_result_t result; + va_list backup; REQUIRE(dest != NULL); REQUIRE(format != NULL); + va_copy(backup, ap); len = vsnprintf(dest->data, dest->allocated, format, ap); if (len > 0) { CHECK(str_alloc(dest, len)); - len = vsnprintf(dest->data, dest->allocated, format, ap); + len = vsnprintf(dest->data, dest->allocated, format, backup); } + va_end(backup); - if (len < 0) + if (len < 0) { result = ISC_R_FAILURE; + goto cleanup; + } return ISC_R_SUCCESS; -- cgit