From 0ecf044080553da8ae149278cd4cc957ed8d559b Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Thu, 8 Jun 2017 10:34:29 -0400 Subject: [PATCH] ecore-drm2: Fix potential SIGFPE when adding output mode If we receive bad crtc info from libdrm, then we could end up with a SIGFPE here due to division by zero if info h/v total are not set. @fix Signed-off-by: Chris Michael --- src/lib/ecore_drm2/ecore_drm2_outputs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index a30d04e0b7..e760c02d74 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c @@ -306,6 +306,10 @@ _output_mode_add(Ecore_Drm2_Output *output, const drmModeModeInfo *info) Ecore_Drm2_Output_Mode *mode; uint64_t refresh; + EINA_SAFETY_ON_NULL_RETURN_VAL(info, NULL); + EINA_SAFETY_ON_FALSE_RETURN_VAL((info->htotal > 0), NULL); + EINA_SAFETY_ON_FALSE_RETURN_VAL((info->vtotal > 0), NULL); + mode = calloc(1, sizeof(Ecore_Drm2_Output_Mode)); if (!mode) return NULL;