summaryrefslogtreecommitdiff
path: root/source4/lib/talloc/talloc.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-03-22 05:51:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:10 -0500
commit689a803ac7600c1d8bff5e33cce1c098a332c02a (patch)
tree7f1f87c486629e9aee57a37323af2292ab94e28f /source4/lib/talloc/talloc.c
parent340d35be2d3f29a3176d86c0960398c2e36f921f (diff)
downloadsamba-689a803ac7600c1d8bff5e33cce1c098a332c02a.tar.gz
samba-689a803ac7600c1d8bff5e33cce1c098a332c02a.tar.bz2
samba-689a803ac7600c1d8bff5e33cce1c098a332c02a.zip
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)
Diffstat (limited to 'source4/lib/talloc/talloc.c')
-rw-r--r--source4/lib/talloc/talloc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index 72765448c7..31796a247b 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -36,6 +36,8 @@
#include <stdarg.h>
#include <stdint.h>
#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;