aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-07 12:38:59 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-03-07 12:38:59 +0100
commit42c23ec1a5a90a97858e469cbc6e88e86a0c43fa (patch)
treec2fda49e989faf67cb9b5324a5bfa2c016a7317d
parentbd3d2aabc350bf256a7b5eed9c7b1b4061cb38a4 (diff)
downloadslcl-42c23ec1a5a90a97858e469cbc6e88e86a0c43fa.tar.gz
main.c: Fix memory leak if append_form fails
-rw-r--r--main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.c b/main.c
index f5de694..7e917fc 100644
--- a/main.c
+++ b/main.c
@@ -177,12 +177,18 @@ static struct form *get_forms(const struct http_payload *const pl,
*outn = 0;
while (*s)
- if (!(forms = append_form(forms, &s, outn)))
+ {
+ struct form *const f = append_form(forms, &s, outn);
+
+ if (!f)
{
fprintf(stderr, "%s: append_form failed\n", __func__);
goto failure;
}
+ forms = f;
+ }
+
free(dup);
return forms;