Fixes following memory leak:
14 bytes in 1 blocks are definitely lost in loss record 1 of 5
at 0x4079514: malloc (vg_replace_malloc.c:309)
by 0x4049A04: vasprintf (vasprintf.c:13)
by 0x4046354: asprintf (asprintf.c:10)
by 0x80491A9: main (in /root/utrace)
134 bytes in 1 blocks are definitely lost in loss record 3 of 5
at 0x4079514: malloc (vg_replace_malloc.c:309)
by 0x4049A04: vasprintf (vasprintf.c:13)
by 0x4046354: asprintf (asprintf.c:10)
by 0x8049208: main (in /root/utrace)
Signed-off-by: Junnan Xu <junnanx.xu@gmail.com>
Reviewed-by: Rui Salvaterra <rsalvaterra@gmail.com>
ULOG_ERR("failed to exec %s: %m\n", _argv[0]);
free(_argv);
+ if (_envp[0])
+ free(_envp[0]);
+ if (newenv == 2 && _envp[1])
+ free(_envp[1]);
free(_envp);
return ret;
}