From 6e30a1ee455bccd1250cee6d1b92a013937dd71c Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Mon, 4 May 2020 14:52:12 +0200 Subject: [PATCH] print: Fix "possible leak" warning by moving initialization For some reason static checkers report that the auto-free is not run if the goto exists the loop. It seems to me like that should work fine, but we can simply make the analysers happy by moving it. --- libfprint/fp-print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libfprint/fp-print.c b/libfprint/fp-print.c index fd4774f..c485975 100644 --- a/libfprint/fp-print.c +++ b/libfprint/fp-print.c @@ -822,7 +822,7 @@ fp_print_deserialize (const guchar *data, fpi_print_set_type (result, FPI_PRINT_NBIS); for (i = 0; i < g_variant_n_children (prints); i++) { - g_autofree struct xyt_struct *xyt = g_new0 (struct xyt_struct, 1); + g_autofree struct xyt_struct *xyt = NULL; const gint32 *xcol, *ycol, *thetacol; gsize xlen, ylen, thetalen; g_autoptr(GVariant) xyt_data = NULL; @@ -848,6 +848,7 @@ fp_print_deserialize (const guchar *data, if (xlen > G_N_ELEMENTS (xyt->xcol)) goto invalid_format; + xyt = g_new0 (struct xyt_struct, 1); xyt->nrows = xlen; memcpy (xyt->xcol, xcol, sizeof (xcol[0]) * xlen); memcpy (xyt->ycol, ycol, sizeof (xcol[0]) * xlen);