summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-asprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/bsd-asprintf.c')
-rw-r--r--openbsd-compat/bsd-asprintf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-asprintf.c b/openbsd-compat/bsd-asprintf.c
index 67480139e..00fa0dfd8 100644
--- a/openbsd-compat/bsd-asprintf.c
+++ b/openbsd-compat/bsd-asprintf.c
@@ -39,7 +39,8 @@
39 39
40#define INIT_SZ 128 40#define INIT_SZ 128
41 41
42int vasprintf(char **str, const char *fmt, va_list ap) 42int
43vasprintf(char **str, const char *fmt, va_list ap)
43{ 44{
44 int ret = -1; 45 int ret = -1;
45 va_list ap2; 46 va_list ap2;
@@ -53,7 +54,7 @@ int vasprintf(char **str, const char *fmt, va_list ap)
53 ret = vsnprintf(string, INIT_SZ, fmt, ap2); 54 ret = vsnprintf(string, INIT_SZ, fmt, ap2);
54 if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ 55 if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */
55 *str = string; 56 *str = string;
56 } else if (ret == INT_MAX) { /* shouldn't happen */ 57 } else if (ret == INT_MAX || ret < 0) { /* Bad length */
57 goto fail; 58 goto fail;
58 } else { /* bigger than initial, realloc allowing for nul */ 59 } else { /* bigger than initial, realloc allowing for nul */
59 len = (size_t)ret + 1; 60 len = (size_t)ret + 1;