aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/includes/helpers.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/includes/helpers.h b/src/includes/helpers.h
index 3657ee74..6e0ad19f 100644
--- a/src/includes/helpers.h
+++ b/src/includes/helpers.h
@@ -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) {
- /* Give up! */
- free(ret);
- return -1;
- }
}
- if (len < 0) {
+ if (len < 0 || len >= memlen) {
+ /* Give up! */
+ fprintf(stderr, "xasprintf: unable to format a buffer\n");
free(ret);
- return -1;
+ exit(1);
}
*strp = ret;
return len;