#7 main.c: memory leak

open
nobody
None
5
2009-10-23
2009-10-23
Anonymous
No

For source code file xzgv-0.8/src/main.c
function read_xvpic

I notice the following poorly formatted code

count=fread(bmap,1,w*h,in);
if(count!=w*h)
return(0);

fclose(in);
return(1);

so if the first return is taken, then local variable "in" is a resource leak.
Suggest new code

count = fread( bmap, 1, w * h, in);
fclose( in);
if (count != w * h)
return 0;
else
return 1;

Discussion