Skip to content

Commit

Permalink
Crash less if no EDID block found in log file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Jackson committed Dec 11, 2006
1 parent ae0de5a commit dd6d901
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions edid-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ extract_edid(int fd)
{
struct stat buf;
unsigned char *ret1 = NULL, *ret2 = NULL;
unsigned char *start, *end, *c;
unsigned char *out = NULL;
int state = 0;
int lines = 0;
int i;

if (fstat(fd, &buf))
Expand All @@ -157,12 +161,11 @@ extract_edid(int fd)
}

/* I think it is, let's go scanning */
unsigned char *start, *end, *c;
unsigned char *out = NULL;
int state = 0;
int lines = 0;
start = strstr(strstr(ret1, "EDID (in hex):"), "(II)");
end = strstr(start, ": \n");
if (!(start = strstr(strstr(ret1, "EDID (in hex):"), "(II)")))
return ret1;
if (!(end = strstr(start, ": \n")))
return ret1;

for (c = start; c < end; c++) {
if (state == 0) {
/* skip ahead to the : */
Expand Down

0 comments on commit dd6d901

Please sign in to comment.