remote: close file on usteer_init_local_id fread fail master
authorChristian Marangi <ansuelsmth@gmail.com>
Mon, 29 May 2023 17:25:32 +0000 (19:25 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Mon, 29 May 2023 17:27:02 +0000 (19:27 +0200)
Fix Coverity Scan CID 1521041 reporting a not closed FILE on fread fail.
Correctly close the FILE on fread fail to fix this leak.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
remote.c

index 9b753e6e7e7a15068f207e275afd2ac4f30c3162..bf58ea3c9564226068b41c39d24dacb7a3282243 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -678,8 +678,10 @@ usteer_init_local_id(void)
                return -1;
        }
 
-       if (fread(&local_id, sizeof(local_id), 1, f) < 1)
+       if (fread(&local_id, sizeof(local_id), 1, f) < 1) {
+               fclose(f);
                return -1;
+       }
 
        fclose(f);
        return 0;