upeksonly: Fix possible division by zero in upeksonly_get_deviation2()

By asserting if we have a zero line width.

libfprint/drivers/upeksonly.c:118:7: warning: Division by zero
        mean /= (ctx->line_width / 2);
        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
Bastien Nocera 2018-12-12 16:10:10 +01:00
parent 6845e400cd
commit 9a025bde8b

View file

@ -112,6 +112,9 @@ static int upeksonly_get_deviation2(struct fpi_line_asmbl_ctx *ctx,
{ {
unsigned char *buf1 = line1->data, *buf2 = line2->data; unsigned char *buf1 = line1->data, *buf2 = line2->data;
int res = 0, mean = 0, i; int res = 0, mean = 0, i;
g_assert (ctx->line_width > 0);
for (i = 0; i < ctx->line_width; i+= 2) for (i = 0; i < ctx->line_width; i+= 2)
mean += (int)buf1[i + 1] + (int)buf2[i]; mean += (int)buf1[i + 1] + (int)buf2[i];