]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http_htx: Fix some leaks on error path when error files are loaded
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Jan 2020 09:10:11 +0000 (10:10 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Jan 2020 10:12:37 +0000 (11:12 +0100)
No backports needed. This patch partially fixes the issue #457.

src/http_htx.c

index 016fd8f2bc9543eaed7bbe154afed910d3eedc5d..d818170f2b6ae6845ceb4af653dde4c06a407b1f 100644 (file)
@@ -946,6 +946,7 @@ struct buffer *http_load_errorfile(const char *file, char **errmsg)
        http_err->node.key = strdup(file);
        if (!http_err->node.key) {
                memprintf(errmsg, "out of memory.");
+               free(http_err);
                goto out;
        }
 
@@ -996,6 +997,7 @@ struct buffer *http_load_errormsg(const char *key, const struct ist msg, char **
        http_err->node.key = strdup(key);
        if (!http_err->node.key) {
                memprintf(errmsg, "out of memory.");
+               free(http_err);
                goto out;
        }
 
@@ -1199,7 +1201,6 @@ static int proxy_parse_errorfiles(char **args, int section, struct proxy *curpx,
        conf_err = calloc(1, sizeof(*conf_err));
        if (!name || !conf_err) {
                memprintf(err, "%s : out of memory.", args[0]);
-               ret = -1;
                goto error;
        }
        conf_err->type = 0;
@@ -1222,8 +1223,7 @@ static int proxy_parse_errorfiles(char **args, int section, struct proxy *curpx,
                        }
                        if (rc >= HTTP_ERR_SIZE) {
                                memprintf(err, "%s : status code '%d' not handled.", args[0], status);
-                               ret = -1;
-                               goto out;
+                               goto error;
                        }
                }
        }
@@ -1236,6 +1236,7 @@ static int proxy_parse_errorfiles(char **args, int section, struct proxy *curpx,
   error:
        free(name);
        free(conf_err);
+       ret = -1;
        goto out;
 }