From 689a803ac7600c1d8bff5e33cce1c098a332c02a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 22 Mar 2005 05:51:41 +0000 Subject: [PATCH] r5938: - allow NULL string argument to talloc_vasprintf_append() - default to using va_copy(), thus assuming a modern libc (This used to be commit 3060b26c9e745330682f6209d97e723113b65b56) --- source4/lib/talloc/talloc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c index 72765448c79..31796a247ba 100644 --- a/source4/lib/talloc/talloc.c +++ b/source4/lib/talloc/talloc.c @@ -36,6 +36,8 @@ #include #include #include "talloc.h" +/* assume a modern system */ +#define HAVE_VA_COPY #endif /* use this to force every realloc to change the pointer, to stress test @@ -946,10 +948,16 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINT static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) { - struct talloc_chunk *tc = talloc_chunk_from_ptr(s); + struct talloc_chunk *tc; int len, s_len; va_list ap2; + if (s == NULL) { + return talloc_vasprintf(NULL, fmt, ap); + } + + tc = talloc_chunk_from_ptr(s); + VA_COPY(ap2, ap); s_len = tc->size - 1; -- 2.34.1