Menu

#11 Memory leak on error in unrrdu_ccfindMain function

Bug
open
nobody
Bug (7)
5
2012-11-26
2012-11-26
Malloc
No

FILE: teem-1.10.0-src/src/unrrdu/ccfind.c
FUNTION: unrrdu_ccfindMain
LINE: 71

There can be an error returned from nrrdCCFind function (line 71) and it still could have set nval to memory created by nrrdNew().
Then the nval memory pointer is lost on the return (line 75).

Looks like if you add a nrrdNuke inside the if statement, like below, the memory leak will be fixed.

if (nrrdCCFind(nout, airStrlen(valS) ? &nval : NULL, nin, type, conny)) {
if(nval) nrrdNuke(nval); // Delete the memory if allocated.
airMopAdd(mop, err = biffGetDone(NRRD), airFree, airMopAlways);
fprintf(stderr, "%s: error doing connected components:\n%s", me, err);
airMopError(mop);
return 1;
}

Discussion


Log in to post a comment.

Auth0 Logo