summaryrefslogtreecommitdiff
path: root/source3/lib/talloc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-02-06 05:58:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:45 -0500
commit5f8840ec844067dba987e8e28d8e96b90338d15c (patch)
treef6b37a0fa76a01c0c2d066d07b28d4efeb6a572c /source3/lib/talloc
parent14785319cccde0e36c07927a6a3b23f52cbfb944 (diff)
downloadsamba-5f8840ec844067dba987e8e28d8e96b90338d15c.tar.gz
r21176: merged va_end() changes from Samba4
(This used to be commit 04f6f01dfeda2fa076209a94cdf8e59f6ce47008)
Diffstat (limited to 'source3/lib/talloc')
-rw-r--r--source3/lib/talloc/talloc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source3/lib/talloc/talloc.c b/source3/lib/talloc/talloc.c
index 15a44bd0d99..028b44a8c72 100644
--- a/source3/lib/talloc/talloc.c
+++ b/source3/lib/talloc/talloc.c
@@ -1174,10 +1174,11 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
va_list ap2;
char c;
- va_copy(ap2, ap);
-
/* this call looks strange, but it makes it work on older solaris boxes */
- if ((len = vsnprintf(&c, 1, fmt, ap2)) < 0) {
+ va_copy(ap2, ap);
+ len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+ if (len < 0) {
return NULL;
}
@@ -1185,6 +1186,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
if (ret) {
va_copy(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);
+ va_end(ap2);
_talloc_set_name_const(ret, ret);
}
@@ -1226,10 +1228,13 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
tc = talloc_chunk_from_ptr(s);
+ s_len = tc->size - 1;
+
va_copy(ap2, ap);
+ len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
- s_len = tc->size - 1;
- if ((len = vsnprintf(&c, 1, fmt, ap2)) <= 0) {
+ if (len <= 0) {
/* Either the vsnprintf failed or the format resulted in
* no characters being formatted. In the former case, we
* ought to return NULL, in the latter we ought to return
@@ -1243,8 +1248,8 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
if (!s) return NULL;
va_copy(ap2, ap);
-
vsnprintf(s+s_len, len+1, fmt, ap2);
+ va_end(ap2);
_talloc_set_name_const(s, s);
return s;