1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-14 12:23:52 +03:00

r13397: Propagate the error return from vsnprintf to trap the case where

we aren't linked against a C99 vsnprintf.
This commit is contained in:
James Peach
2006-02-08 23:44:17 +00:00
committed by Gerald (Jerry) Carter
parent 443677f58d
commit 23782f899a

View File

@@ -1011,7 +1011,9 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
VA_COPY(ap2, ap);
len = vsnprintf(NULL, 0, fmt, ap2);
if ((len = vsnprintf(NULL, 0, fmt, ap2)) <= 0) {
return NULL;
}
ret = _talloc(t, len+1);
if (ret) {
@@ -1060,7 +1062,15 @@ char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
VA_COPY(ap2, ap);
s_len = tc->size - 1;
len = vsnprintf(NULL, 0, fmt, ap2);
if ((len = vsnprintf(NULL, 0, fmt, ap2)) <= 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
* the original string. Most current callers of this
* function expect it to never return NULL.
*/
return s;
}
s = talloc_realloc(NULL, s, char, s_len + len+1);
if (!s) return NULL;