Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 5b33d7a

Browse files
authored
Merge pull request #236 from laijs/fix-memory-leak
fix memory leak in hyper_free_exec()
2 parents 1117695 + 96b38d7 commit 5b33d7a

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

src/exec.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,16 +580,7 @@ static void hyper_exec_process(struct hyper_exec *exec, struct stdio_config *io)
580580

581581
static void hyper_free_exec(struct hyper_exec *exec)
582582
{
583-
int i;
584-
585-
free(exec->container_id);
586-
587-
for (i = 0; i < exec->argc; i++) {
588-
//fprintf(stdout, "argv %d %s\n", i, exec->argv[i]);
589-
free(exec->argv[i]);
590-
}
591-
592-
free(exec->argv);
583+
hyper_cleanup_exec(exec);
593584
free(exec);
594585
}
595586

src/parse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int container_parse_argv(struct hyper_exec *exec, char *json, jsmntok_t *
181181
return i;
182182
}
183183

184-
static void container_cleanup_exec(struct hyper_exec *exec)
184+
void hyper_cleanup_exec(struct hyper_exec *exec)
185185
{
186186
int i;
187187

@@ -610,7 +610,7 @@ void hyper_free_container(struct hyper_container *c)
610610
container_free_ports(c);
611611
container_free_sysctl(c);
612612
container_free_fsmap(c);
613-
container_cleanup_exec(&c->exec);
613+
hyper_cleanup_exec(&c->exec);
614614

615615
list_del_init(&c->list);
616616
free(c);
@@ -1386,7 +1386,7 @@ struct hyper_exec *hyper_parse_execcmd(char *json, int length)
13861386
free(toks);
13871387
return exec;
13881388
fail:
1389-
container_cleanup_exec(exec);
1389+
hyper_cleanup_exec(exec);
13901390
free(exec);
13911391
exec = NULL;
13921392
goto out;

src/parse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ struct hyper_interface *hyper_parse_setup_interface(char *json, int length);
1717
void hyper_free_interface(struct hyper_interface *iface);
1818
int hyper_parse_setup_routes(struct hyper_route **routes, uint32_t *r_num, char *json, int length);
1919
JSON_Value *hyper_json_parse(char *json, int length);
20-
20+
void hyper_cleanup_exec(struct hyper_exec *exec);
2121
#endif

0 commit comments

Comments
 (0)