From ce856efa257587359a5c4d6b9c990dd134724a70 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 12 Dec 2018 16:30:26 +0100 Subject: [PATCH] elan: Assert on a possible division by zero in elan_need_calibration() libfprint/drivers/elan.c:598:10: warning: Division by zero bg_mean /= frame_size; ~~~~~~~~^~~~~~~~~~~~~ --- libfprint/drivers/elan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libfprint/drivers/elan.c b/libfprint/drivers/elan.c index ea84e7c..3020f05 100644 --- a/libfprint/drivers/elan.c +++ b/libfprint/drivers/elan.c @@ -595,6 +595,8 @@ static int elan_need_calibration(struct elan_dev *elandev) unsigned int bg_mean = 0, delta; unsigned int frame_size = elandev->frame_width * elandev->frame_height; + g_assert(frame_size != 0); + for (int i = 0; i < frame_size; i++) bg_mean += elandev->background[i]; bg_mean /= frame_size;