From 071b95e683d9bda7267f7bdd8d146ad2575f22b5 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Thu, 23 Sep 2021 10:32:45 +1000 Subject: [PATCH] roken: fix theoretical leak introduced in 7fbe7be6 split_spec() should free output parameters if it fails. This was not a leak in practice because its single caller cleaned up anyway, but cleaning up for good hygiene. --- lib/roken/roken_gethostby.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/roken/roken_gethostby.c b/lib/roken/roken_gethostby.c index f7b5086c4..a2febd0d1 100644 --- a/lib/roken/roken_gethostby.c +++ b/lib/roken/roken_gethostby.c @@ -102,8 +102,11 @@ split_spec(const char *spec, char **host, int *port, char **path, int def_port) if(p) { if(path) { *path = strdup(p); - if (*path == NULL) + if (*path == NULL) { + free(*host); + *host = NULL; return -1; + } } *p = '\0'; }else