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.
This commit is contained in:
Luke Howard
2021-09-23 10:32:45 +10:00
parent 8fc67658a6
commit 071b95e683

View File

@@ -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