fix missing va_end() calls

Tue, 16 Jan 2024 23:15:36 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 16 Jan 2024 23:15:36 +0100
changeset 811
b02ad05c7f2d
parent 810
85859399a0cc
child 812
fda0f1910d7e

fix missing va_end() calls

src/printf.c file | annotate | diff | comparison | revisions
--- a/src/printf.c	Tue Jan 16 23:13:01 2024 +0100
+++ b/src/printf.c	Tue Jan 16 23:15:36 2024 +0100
@@ -61,17 +61,21 @@
     va_copy(ap2, ap);
     int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap);
     if (ret < 0) {
+        va_end(ap2);
         return ret;
     } else if (ret < CX_PRINTF_SBO_SIZE) {
+        va_end(ap2);
         return (int) wfc(buf, 1, ret, stream);
     } else {
         int len = ret + 1;
         char *newbuf = malloc(len);
         if (!newbuf) {
+            va_end(ap2);
             return -1;
         }
 
         ret = vsnprintf(newbuf, len, fmt, ap2);
+        va_end(ap2);
         if (ret > 0) {
             ret = (int) wfc(newbuf, 1, ret, stream);
         }
@@ -124,6 +128,7 @@
             }
         }
     }
+    va_end(ap2);
     return s;
 }
 

mercurial