From 2718dc02e0599ce9c12795f363dbf8ef118599b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 27 Sep 2022 23:32:57 +0200 Subject: [PATCH] vfs0050: Initialize the usb transfer buffer when allocating it Ensure that the memory that we're going to populate via USB transfer is initialized, otherwise valgrind may complain about (even if that's not really an issue). --- libfprint/drivers/vfs0050.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libfprint/drivers/vfs0050.c b/libfprint/drivers/vfs0050.c index dc77f542..2442937a 100644 --- a/libfprint/drivers/vfs0050.c +++ b/libfprint/drivers/vfs0050.c @@ -581,7 +581,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev) /* Initialize fingerprint buffer */ g_free (self->lines_buffer); self->memory = VFS_USB_BUFFER_SIZE; - self->lines_buffer = g_malloc (self->memory); + self->lines_buffer = g_malloc0 (self->memory); self->bytes = 0; /* Finger is on the scanner */ @@ -589,12 +589,15 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev) } /* Increase buffer size while it's insufficient */ - while (self->bytes + VFS_USB_BUFFER_SIZE > self->memory) + while (self->memory < self->bytes + VFS_USB_BUFFER_SIZE) { - self->memory <<= 1; + int pre_memory = self->memory; + self->memory += VFS_USB_BUFFER_SIZE; self->lines_buffer = (struct vfs_line *) g_realloc (self->lines_buffer, self->memory); + memset ((guint8 *) self->lines_buffer + pre_memory, 0, + VFS_USB_BUFFER_SIZE); } /* Receive chunk of data */