wachub / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

Memory leak issue occur in function mg_start #325

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Call function mg_start when parameter "options" contain same-name option items, 
memory leak occur at this line:
    ctx->config[i] = mg_strdup(value);
To fix:
    free memory if config[i] have assigned value, new code:
    if (ctx->config[i] != NULL)
        free(ctx->config[i]);
    ctx->config[i] = mg_strdup(value);

What is the expected output? What do you see instead?
be independent of system. found the issue by code review 

Original issue reported on code.google.com by yuj...@gmail.com on 10 Mar 2012 at 4:08

GoogleCodeExporter commented 9 years ago
The right way is to fail rather then silently change the value.
It is an error to pass duplicate option values, and depending on the order of 
options.
Submitted 
http://code.google.com/p/mongoose/source/detail?r=fcf46aac017259da32e21a10d6256c
6ab797cfd4, thanks!

Original comment by valenok on 11 Mar 2012 at 10:16