libfprint/SOURCES/0157-fpi-assembling-Accept-error-of-zero.patch
2021-09-09 20:12:48 +00:00

39 lines
1.0 KiB
Diff

From 09f55e077d69eee3be745be740363151b7b10c8d Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Fri, 6 Dec 2019 18:54:49 +0100
Subject: [PATCH 157/181] fpi-assembling: Accept error of zero
Rather than discarding a zero error, check that the constraints are
sane. This way a perfect match is possible.
---
libfprint/fpi-assembling.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libfprint/fpi-assembling.c b/libfprint/fpi-assembling.c
index 2b55ee3..a809a2d 100644
--- a/libfprint/fpi-assembling.c
+++ b/libfprint/fpi-assembling.c
@@ -52,6 +52,9 @@ calc_error (struct fpi_frame_asmbl_ctx *ctx,
width = ctx->frame_width - (dx > 0 ? dx : -dx);
height = ctx->frame_height - dy;
+ if (height == 0 || width == 0)
+ return INT_MAX;
+
y1 = 0;
y2 = dy;
i = 0;
@@ -86,9 +89,6 @@ calc_error (struct fpi_frame_asmbl_ctx *ctx,
err *= (ctx->frame_height * ctx->frame_width);
err /= (height * width);
- if (err == 0)
- return INT_MAX;
-
return err;
}
--
2.24.1