From: Daniel Golle Date: Mon, 30 Aug 2021 19:11:30 +0000 (+0100) Subject: libfstools: make sure file is closed on error X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=19fd7fc24129d931c755a815313d81bcfa66859a;p=project%2Ffstools.git libfstools: make sure file is closed on error Coverity CID: 1330286 Resource leak Signed-off-by: Daniel Golle --- 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);