On 9/30/19 7:13 PM, Breno Leitao wrote:
> There are some weird monitors that returns invalid data, as zeroed
> Horizontal/Vertical Active/Blanking.
> 
> This causes edid-decode to crash with a divsion by error exception. This
> simple patch avoids so, checking for the divisor before proceeding.
> 
> Signed-off-by: Breno Leitao <lei...@debian.org>
> ---
>  edid-decode.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/edid-decode.c b/edid-decode.c
> index 7442f8a..4b2cef8 100644
> --- a/edid-decode.c
> +++ b/edid-decode.c
> @@ -1022,6 +1022,17 @@ static int detailed_block(const unsigned char *x,
> int in_extension)

This should have been on one line, it looks like your mailer is wrapping lines.

>               break;
>       }
> 
> +     if ((ha + hbl) == 0 ||
> +         (va + vbl) == 0) {

I'd use '!ha || !hbl || !va || !vbl' here.



> +             printf("Invalid data. Refusing to continue.\n"

I'd say: "Invalid Detailing Timings:" here.

> +                    "Horizontal Active %4d\n"
> +                    "Horizontal Blanking %4d\n"
> +                    "Vertical Active %4d\n"
> +                    "Vertical Blanking %4d\n",
> +                    ha, hbl, va, vbl);
> +             return 0;
> +     }
> +
>       pixclk_khz = (x[0] + (x[1] << 8)) * 10;
>       refresh = (pixclk_khz * 1000) / ((ha + hbl) * (va + vbl));
>       printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
> 

I'm happy to take this if you post a v2 with these changes!

Regards,

        Hans

Reply via email to