session.c: fix memory leak

Reported-by: Jan Beich (@jbeich)
This commit is contained in:
Johan Malm 2020-10-28 20:44:35 +00:00
parent e99e1003d0
commit 36d9496149

View file

@ -99,14 +99,15 @@ session_autostart_init(void)
} }
if (!isfile(autostart)) { if (!isfile(autostart)) {
warn("no autostart file"); warn("no autostart file");
return; goto out;
} }
info("sh autostart file (%s)", autostart); info("run autostart file (%s)", autostart);
int len = strlen(autostart) + 4; int len = strlen(autostart) + 4;
char *cmd = calloc(len, 1); char *cmd = calloc(len, 1);
strcat(cmd, "sh "); strcat(cmd, "sh ");
strcat(cmd, autostart); strcat(cmd, autostart);
spawn_async_no_shell(cmd); spawn_async_no_shell(cmd);
free(cmd); free(cmd);
out:
free((void*)autostart); free((void*)autostart);
} }