summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-04-24 12:36:58 +0200
committerMartin Nagy <mnagy@redhat.com>2009-04-24 14:53:40 +0200
commit7f7a0c023fa83fcb7443bdee523464d4673de40c (patch)
treebe903f243618fcf447a542e2a439ee8b9a538398
parentf221f70dfe242e56743fc1c5814de9bdcb7ee527 (diff)
downloadldap_driver_testing-7f7a0c023fa83fcb7443bdee523464d4673de40c.tar.gz
ldap_driver_testing-7f7a0c023fa83fcb7443bdee523464d4673de40c.tar.xz
ldap_driver_testing-7f7a0c023fa83fcb7443bdee523464d4673de40c.zip
Fix a nasty va_list bug.
We were using the same va_list twice, which caused a nasty segfault inside the C library.
-rw-r--r--src/str.c9
1 files changed, 7 insertions, 2 deletions
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;