Skip to content

Commit

Permalink
Properly handle input > 1K for EDID exiting in log files
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 95019a3 commit e55b8eb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,32 @@ extract_edid(int fd)
int out_index = 0;
int len, size;

ret = malloc(1024);
size = 1024;
size = 1 << 10;
ret = malloc(size);
len = 0;

if (ret == NULL)
return NULL;

for (;;) {
i = read(fd, ret + len, size - len);
if (i < 0) {
free(ret);
return 0;
return NULL;
}
if (i == 0)
break;
len += i;
if (len == size)
ret = realloc(ret, size + 1024);
if (len == size) {
char *t;
size <<= 1;
t = realloc(ret, size);
if (t == NULL) {
free(ret);
return NULL;
}
ret = t;
}
}

start = strstr(ret, "EDID_DATA:");
Expand Down

0 comments on commit e55b8eb

Please sign in to comment.