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

Commit 96b38d7

Browse files
committed
fix memory leak in hyper_free_exec()
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
1 parent 2f3040a commit 96b38d7

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
@@ -180,7 +180,7 @@ static int container_parse_argv(struct hyper_exec *exec, char *json, jsmntok_t *
180180
return i;
181181
}
182182

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

@@ -609,7 +609,7 @@ void hyper_free_container(struct hyper_container *c)
609609
container_free_ports(c);
610610
container_free_sysctl(c);
611611
container_free_fsmap(c);
612-
container_cleanup_exec(&c->exec);
612+
hyper_cleanup_exec(&c->exec);
613613

614614
list_del_init(&c->list);
615615
free(c);
@@ -1385,7 +1385,7 @@ struct hyper_exec *hyper_parse_execcmd(char *json, int length)
13851385
free(toks);
13861386
return exec;
13871387
fail:
1388-
container_cleanup_exec(exec);
1388+
hyper_cleanup_exec(exec);
13891389
free(exec);
13901390
exec = NULL;
13911391
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)