xasprintf: exit if return value of vsnprintf is invalid
This commit is contained in:
parent
4616f8f809
commit
68b9b0bc2a
@ -158,15 +158,12 @@ _unused static int xasprintf(char **strp, const char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(ret, len + 1, fmt, ap);
|
||||
va_end(ap);
|
||||
if (len >= memlen) {
|
||||
}
|
||||
if (len < 0 || len >= memlen) {
|
||||
/* Give up! */
|
||||
fprintf(stderr, "xasprintf: unable to format a buffer\n");
|
||||
free(ret);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (len < 0) {
|
||||
free(ret);
|
||||
return -1;
|
||||
exit(1);
|
||||
}
|
||||
*strp = ret;
|
||||
return len;
|
||||
|
Loading…
Reference in New Issue
Block a user