ufairiya / mongoose

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

static code analysis reports problem in mg_modify_passwords_field #222

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
2489        /* Create the file if does not exist */
2490        if ((fp = mg_fopen(fname, "a+")) != NULL)
2491                (void) fclose(fp);
2492
2493        /* Open the given file and temporary file */
At conditional (1): "(fp = fopen(fname, "r")) == NULL" taking the false branch.
Calling allocation function "fopen".
Assigning: "fp" = storage returned from "fopen(fname, "r")".
2494        if ((fp = mg_fopen(fname, "r")) == NULL) {
2495                cry(fc(ctx), "Cannot open %s: %s", fname, strerror(errno));
2496                return (0);
At conditional (2): "(fp2 = fopen(tmp, "w+")) == NULL" taking the true branch.
2497        } else if ((fp2 = mg_fopen(tmp, "w+")) == NULL) {
2498                cry(fc(ctx), "Cannot open %s: %s", tmp, strerror(errno));
Variable "fp" going out of scope leaks the storage it points to.
2499                return (0);
2500        }

Original issue reported on code.google.com by cruppst...@gmail.com on 24 Jan 2011 at 12:15

GoogleCodeExporter commented 9 years ago
Thank you. This leak has been fixed by 
http://code.google.com/p/mongoose/source/detail?r=21719ae25ae6a58f97ec447a7a4739
723912750b

Original comment by valenok on 19 Feb 2011 at 11:58