[Chilli] [PATCH] Fix: Memory leak of opt_run()

David Bird david at coova.com
Fri Mar 5 08:08:47 UTC 2010


Hello,

I still don't see the problem. In opt_run(), one of the first things it
does is a fork() and returns the parent process out of the function. The
child continues, and allocated the memory in question, before going into
execv(), which replaces the process. I believe your free(newargs_bk) in
options_destroy() is trying to free uninitialized memory (newargs_bk
isn't initialized in the parent, only the child). So, the question is,
do you think memory is being leaked in the parent or child process? I
would only be concerned about leaking memory in the parent (chilli)
process as the child process is short-lived. 

David

On Fri, 2010-03-05 at 15:45 +0900, Masashi Honma wrote:
> (2010/03/05 15:38), Masashi Honma wrote:
> > static int opt_run(int argc, char **argv, int reload) {
> > char **newargs;
> > char file[128];
> >
> > newargs_bk = newargs; <-- add
> 
> 
> I omitted many lines. Right position is here.
> 
>    if (!(newargs = calloc(1, sizeof(char *) * (argc + 4)))) {
>      return -1;
>    }
> 
>    newargs_bk = newargs; <-- add
> 
>    for (i=1; i < argc; i++) {
>      newargs[i] = argv[i];
>    }
> 
> Regards,
> Masashi Honma.
> _______________________________________________
> Chilli mailing list
> Chilli at coova.org
> http://lists.coova.org/cgi-bin/mailman/listinfo/chilli




More information about the Chilli mailing list