From 174865b71c02bcacb8b30749e2c3c0db7b5d2bf2 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 27 Dec 2021 18:25:28 +0100 Subject: [PATCH] Fix malloc/alloca --- src/lib/config.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/config.c b/src/lib/config.c index 25b1550..9a14886 100644 --- a/src/lib/config.c +++ b/src/lib/config.c @@ -68,7 +68,7 @@ int config_load(const char *filename) { fseek(file, 0, SEEK_END); unsigned long len = ftell(file); fseek(file, 0, SEEK_SET); - char *conf = malloc(len); + char *conf = alloca(len); fread(conf, 1, len, file); fclose(file); @@ -206,7 +206,6 @@ int config_load(const char *filename) { while (source[0] == ' ' || source[0] == '\t') source++; if (strlen(source) == 0) { err: - free(conf); free(tmp_config); fprintf(stderr, ERR_STR "Unable to parse config file (line %i)" CLR_STR "\n", line); return -2; @@ -228,7 +227,6 @@ int config_load(const char *filename) { tmp_config->hosts[i - 1].rev_proxy.port = (unsigned short) strtoul(source, NULL, 10); } } - free(conf); for (int k = 0; k < i; k++) { host_config *hc = &tmp_config->hosts[k];