mirror of
https://github.com/samba-team/samba.git
synced 2025-09-02 01:49:29 +03:00
r21176: merged va_end() changes from Samba4
(This used to be commit 04f6f01dfe
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
14785319cc
commit
5f8840ec84
@ -742,6 +742,8 @@ static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in
|
|||||||
ret = currlen;
|
ret = currlen;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
while (chunks) {
|
while (chunks) {
|
||||||
cnk = chunks->next;
|
cnk = chunks->next;
|
||||||
free(chunks);
|
free(chunks);
|
||||||
@ -1260,16 +1262,16 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
|
|||||||
va_list ap2;
|
va_list ap2;
|
||||||
|
|
||||||
VA_COPY(ap2, ap);
|
VA_COPY(ap2, ap);
|
||||||
|
|
||||||
ret = vsnprintf(NULL, 0, format, ap2);
|
ret = vsnprintf(NULL, 0, format, ap2);
|
||||||
|
va_end(ap2);
|
||||||
if (ret <= 0) return ret;
|
if (ret <= 0) return ret;
|
||||||
|
|
||||||
(*ptr) = (char *)malloc(ret+1);
|
(*ptr) = (char *)malloc(ret+1);
|
||||||
if (!*ptr) return -1;
|
if (!*ptr) return -1;
|
||||||
|
|
||||||
VA_COPY(ap2, ap);
|
VA_COPY(ap2, ap);
|
||||||
|
|
||||||
ret = vsnprintf(*ptr, ret+1, format, ap2);
|
ret = vsnprintf(*ptr, ret+1, format, ap2);
|
||||||
|
va_end(ap2);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1174,10 +1174,11 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
|
|||||||
va_list ap2;
|
va_list ap2;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
|
||||||
|
|
||||||
/* this call looks strange, but it makes it work on older solaris boxes */
|
/* 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,6 +1186,7 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
vsnprintf(ret, len+1, fmt, ap2);
|
vsnprintf(ret, len+1, fmt, ap2);
|
||||||
|
va_end(ap2);
|
||||||
_talloc_set_name_const(ret, ret);
|
_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);
|
tc = talloc_chunk_from_ptr(s);
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
|
||||||
|
|
||||||
s_len = tc->size - 1;
|
s_len = tc->size - 1;
|
||||||
if ((len = vsnprintf(&c, 1, fmt, ap2)) <= 0) {
|
|
||||||
|
va_copy(ap2, ap);
|
||||||
|
len = vsnprintf(&c, 1, fmt, ap2);
|
||||||
|
va_end(ap2);
|
||||||
|
|
||||||
|
if (len <= 0) {
|
||||||
/* Either the vsnprintf failed or the format resulted in
|
/* Either the vsnprintf failed or the format resulted in
|
||||||
* no characters being formatted. In the former case, we
|
* no characters being formatted. In the former case, we
|
||||||
* ought to return NULL, in the latter we ought to return
|
* 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;
|
if (!s) return NULL;
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
|
|
||||||
vsnprintf(s+s_len, len+1, fmt, ap2);
|
vsnprintf(s+s_len, len+1, fmt, ap2);
|
||||||
|
va_end(ap2);
|
||||||
_talloc_set_name_const(s, s);
|
_talloc_set_name_const(s, s);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
Reference in New Issue
Block a user