From 19fd7fc24129d931c755a815313d81bcfa66859a Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 30 Aug 2021 20:11:30 +0100 Subject: libfstools: make sure file is closed on error Coverity CID: 1330286 Resource leak Signed-off-by: Daniel Golle --- libfstools/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libfstools/common.c b/libfstools/common.c index c484776..8dc1095 100644 --- a/libfstools/common.c +++ b/libfstools/common.c @@ -36,8 +36,10 @@ char if (!f) return NULL; - if (fgets(buf, bufsz, f) == NULL) + if (fgets(buf, bufsz, f) == NULL) { + fclose(f); return NULL; + } fclose(f); -- cgit v1.2.1