From 55b83062d040bd9e52ba9a2f11d363601072f7b5 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 25 May 2018 13:30:35 +0200 Subject: [PATCH] img: Fix fd leaks Spotted by maddin200@aol.com https://bugs.freedesktop.org/show_bug.cgi?id=90197 --- libfprint/img.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libfprint/img.c b/libfprint/img.c index 10511f8..d0ca6fb 100644 --- a/libfprint/img.c +++ b/libfprint/img.c @@ -166,12 +166,14 @@ API_EXPORTED int fp_img_save_to_file(struct fp_img *img, char *path) r = fprintf(fd, "P5 %d %d 255\n", img->width, img->height); if (r < 0) { + fclose(fd); fp_err("pgm header write failed, error %d", r); return r; } r = fwrite(img->data, 1, write_size, fd); if (r < write_size) { + fclose(fd); fp_err("short write (%d)", r); return -EIO; } -- 2.17.0