]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: contrib/modsecurity: close the va_list ap before return
authorDragan Dosen <ddosen@haproxy.com>
Mon, 18 Sep 2017 07:20:43 +0000 (09:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 18 Sep 2017 09:18:34 +0000 (11:18 +0200)
Make sure the va_list ap is closed before return in case the function
vsnprintf() returned an error.

contrib/modsecurity/modsec_wrapper.c

index 8927b5bf4650707ad54c517f7740e3638d49036c..271ec15d1ded27c286067354ea678f36adbced6d 100644 (file)
@@ -105,9 +105,10 @@ static char *printf_dup(struct request_rec *req, char *fmt, ...)
 
        va_start(ap, fmt);
        len = vsnprintf(NULL, 0, fmt, ap);
+       va_end(ap);
+
        if (len == -1)
                return NULL;
-       va_end(ap);
 
        out = apr_pcalloc(req->pool, len + 1);
        if (!out)
@@ -115,9 +116,10 @@ static char *printf_dup(struct request_rec *req, char *fmt, ...)
 
        va_start(ap, fmt);
        len = vsnprintf(out, len + 1, fmt, ap);
+       va_end(ap);
+
        if (len == -1)
                return NULL;
-       va_end(ap);
 
        return out;
 }