From 81e198c034d7c6099619e66bb0eeba4767534eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 24 Apr 2020 19:59:55 +0200 Subject: [PATCH] image: Return an error if we got an empty or NULL minutiae array In some cases nbim's get_minutiae returns no minutiae without providing an error code, and if this happens we would crash in the task callback function as we would try to deference the data->minutiae pointer. Related to: #251 --- libfprint/fp-image.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libfprint/fp-image.c b/libfprint/fp-image.c index 0bcee64..2e46e92 100644 --- a/libfprint/fp-image.c +++ b/libfprint/fp-image.c @@ -314,6 +314,14 @@ fp_image_detect_minutiae_thread_func (GTask *task, return; } + if (!data->minutiae || data->minutiae->num == 0) + { + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, + "No minutiae found"); + g_object_unref (task); + return; + } + g_task_return_boolean (task, TRUE); g_object_unref (task); }