mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
nasmlib/asprintf: check the return value from vsnprintf()
Without this, gcc may throw a warning which breaks the --enable-werror build. It is good practice anyway... Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
ada267ec8c
commit
0b73367874
2 changed files with 8 additions and 4 deletions
|
|
@ -52,15 +52,19 @@ void *nasm_vaxprintf(size_t extra, const char *fmt, va_list ap)
|
|||
char *strp;
|
||||
va_list xap;
|
||||
size_t bytes;
|
||||
int len;
|
||||
|
||||
va_copy(xap, ap);
|
||||
bytes = vsnprintf(NULL, 0, fmt, xap) + 1;
|
||||
len = vsnprintf(NULL, 0, fmt, xap);
|
||||
nasm_assert(len >= 0);
|
||||
bytes = (size_t)len + 1;
|
||||
_nasm_last_string_size = bytes;
|
||||
va_end(xap);
|
||||
|
||||
strp = nasm_malloc(extra+bytes);
|
||||
memset(strp, 0, extra);
|
||||
vsnprintf(strp+extra, bytes, fmt, ap);
|
||||
len = vsnprintf(strp+extra, bytes, fmt, ap);
|
||||
nasm_assert(bytes == (size_t)len + 1);
|
||||
return strp;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue