From 004a211f6cc58ea3ae5ba780e0cb73364b6e6bbe Mon Sep 17 00:00:00 2001 From: Abhinav Baid Date: Mon, 17 Jun 2024 20:33:48 +0100 Subject: [PATCH] Address review comments, fix valgrind --- libfprint/drivers/crfpmoc/crfpmoc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libfprint/drivers/crfpmoc/crfpmoc.c b/libfprint/drivers/crfpmoc/crfpmoc.c index 29579900..5f85ab1e 100644 --- a/libfprint/drivers/crfpmoc/crfpmoc.c +++ b/libfprint/drivers/crfpmoc/crfpmoc.c @@ -112,13 +112,13 @@ crfpmoc_set_print_data (FpPrint *print, gint8 template) static int crfpmoc_ec_command (FpiDeviceCrfpMoc *self, int command, int version, const void *outdata, int outsize, void *indata, int insize, const gchar **error_msg) { - struct crfpmoc_cros_ec_command_v2 *s_cmd; + g_autofree struct crfpmoc_cros_ec_command_v2 *s_cmd = NULL; int r; g_assert (outsize == 0 || outdata != NULL); g_assert (insize == 0 || indata != NULL); - s_cmd = g_malloc (sizeof (struct crfpmoc_cros_ec_command_v2) + MAX (outsize, insize)); + s_cmd = g_malloc0 (sizeof (struct crfpmoc_cros_ec_command_v2) + MAX (outsize, insize)); if (s_cmd == NULL) { if (error_msg != NULL) @@ -161,8 +161,6 @@ crfpmoc_ec_command (FpiDeviceCrfpMoc *self, int command, int version, const void if (error_msg != NULL) *error_msg = crfpmoc_strresult (s_cmd->result); - g_free (s_cmd); - return r; }