commit 2496eff57d80b2ad2534d892719ab81ca5cf1666
parent 3c61e28f4d58a072685d590566a48116a068e919
Author: Ed van Bruggen <edvb54@gmail.com>
Date: Sun, 16 Apr 2017 21:19:25 -0700
Fix memory leak
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tim.c b/tim.c
@@ -96,9 +96,8 @@ get_tim_ans(char *s)
char args[MAX_CMD];
s = str_replace(s, "to", "");
- s = str_rmspaces(s);
- cmds = str_split(s, ' ', &c);
- free(s);
+ char *tmp = str_rmspaces(s);
+ cmds = str_split(tmp, ' ', &c);
if (c > 2) {
if (strcmp(cmds[1], "my") == 0)
@@ -119,6 +118,12 @@ get_tim_ans(char *s)
ans = tim_lua_run(get_path("plugins/json-set.lua"), args);
}
+ free(s);
+ free(tmp);
+ for (int j = 0; j < c; j++)
+ free(cmds[j]);
+ free(cmds);
+
return ans;
}