OSDN Git Service

efi_loadopt_args_from_file(): fix leaked file descriptor.
authorPeter Jones <pjones@redhat.com>
Mon, 1 May 2017 18:40:26 +0000 (14:40 -0400)
committerPeter Jones <pjones@redhat.com>
Mon, 1 May 2017 20:00:33 +0000 (16:00 -0400)
In the case where we're just trying to figure out the file's size, we're
failing to close the file.  So close it.

Found by covscan.

Signed-off-by: Peter Jones <pjones@redhat.com>
src/loadopt.c

index ce88986..a3c1ba9 100644 (file)
@@ -275,8 +275,10 @@ efi_loadopt_args_from_file(uint8_t *buf, ssize_t size, char *filename)
        if (rc < 0)
                goto err;
 
-       if (size == 0)
+       if (size == 0) {
+               fclose(f);
                return statbuf.st_size;
+       }
 
        if (size < statbuf.st_size) {
                errno = ENOSPC;