diff options
Diffstat (limited to 'extract/src/mem.c')
-rw-r--r-- | extract/src/mem.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/extract/src/mem.c b/extract/src/mem.c index 83b5032c..1c3c96e6 100644 --- a/extract/src/mem.c +++ b/extract/src/mem.c @@ -19,16 +19,26 @@ void extract_bzero(void *b, size_t len) int extract_vasprintf(extract_alloc_t* alloc, char** out, const char* format, va_list va) { int n; - int n2; + int ret; va_list va2; va_copy(va2, va); n = vsnprintf(NULL, 0, format, va); - if (n < 0) return n; - if (extract_malloc(alloc, out, n + 1)) return -1; - n2 = vsnprintf(*out, n + 1, format, va2); + if (n < 0) + { + ret = n; + goto end; + } + if (extract_malloc(alloc, out, n + 1)) + { + ret = -1; + goto end; + } + vsnprintf(*out, n + 1, format, va2); + ret = 0; + + end: va_end(va2); - assert(n2 == n); - return n2; + return ret; } |