Skip to content

Commit

Permalink
Fix some memory leaks in ENOMEM handling
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
  • Loading branch information
jeremyhu committed Oct 8, 2011
1 parent cf95ba5 commit d65ad6a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,13 @@ extract_edid(int fd)
const char indentation1[] = " ";
const char indentation2[] = "\t\t";
const char *indentation;
unsigned char *out;
char *s;

out = malloc(128);
if (out == NULL)
if (out == NULL) {
free(ret);
return NULL;
}

for (i = 0; i < 8; i++) {
int j;
Expand Down Expand Up @@ -767,7 +768,13 @@ extract_edid(int fd)
c++;
state = 1;
lines++;
out = realloc(out, lines * 16);
s = realloc(out, lines * 16);
if (!s) {
free(ret);
free(out);
return NULL;
}
out = s;
} else if (state == 1) {
char buf[3];
/* Read a %02x from the log */
Expand Down

0 comments on commit d65ad6a

Please sign in to comment.