Chameleon

Chameleon Commit Details

Date:2014-01-07 09:40:00 (10 years 3 months ago)
Author:Chuck Fry
Commit:2314
Parents: 2313
Message:Fix memory leak, add a check for malloc() failure
Changes:
M/branches/chucko/i386/boot2/picopng.c

File differences

branches/chucko/i386/boot2/picopng.c
10971097
10981098
10991099
1100
1101
11021100
11031101
11041102
11051103
1106
1104
1105
1106
1107
1108
1109
1110
1111
1112
11071113
1114
1115
11081116
11091117
11101118
printf("file empty\n");
return 1;
}
insize = (uint32_t) statbuf.st_size;
inbuf = malloc(insize);
infp = fopen(fname, "rb");
if (!infp) {
perror("fopen");
return 1;
} else if (fread(inbuf, 1, insize, infp) != insize) {
}
insize = (uint32_t) statbuf.st_size;
inbuf = malloc(insize);
if (!inbuf) {
perror("malloc");
fclose(infp);
return 1;
}
if (fread(inbuf, 1, insize, infp) != insize) {
perror("fread");
free(inbuf);
fclose(infp);
return 1;
}
fclose(infp);

Archive Download the corresponding diff file

Revision: 2314