There are some weird monitors that returns invalid data, as zeroed
Horizontal/Vertical Active/Blanking.

This causes edid-decode to crash with a division by zero exception. This simple
patch avoids so, checking for the divisor before proceeding.

Signed-off-by: Breno Leitao <lei...@debian.org>
---
 edid-decode.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/edid-decode.c b/edid-decode.c
index 7442f8a..b932179 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int 
in_extension)
                break;
        }
 
+       if (!ha || !hbl || !va || !vbl) {
+               printf("Invalid Detailing Timings:\n"
+                      "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"
-- 
2.17.1

Reply via email to