]> Git Repo - qemu.git/commitdiff
loader: fix a file descriptor leak
authorBlue Swirl <[email protected]>
Wed, 12 Jan 2011 19:48:57 +0000 (19:48 +0000)
committerBlue Swirl <[email protected]>
Wed, 12 Jan 2011 19:48:57 +0000 (19:48 +0000)
Fix a file descriptor leak, reported by cppcheck:
[/src/qemu/hw/loader.c:311]: (error) Resource leak: fd

Signed-off-by: Blue Swirl <[email protected]>
hw/loader.c

index eb198f67239ef6c685f43b79d70bdc078b53ab87..35d792e6477a1aa6ed3319208b35f7be8df34e19 100644 (file)
@@ -307,8 +307,9 @@ int load_elf(const char *filename, uint64_t (*translate_fn)(void *, uint64_t),
         target_data_order = ELFDATA2LSB;
     }
 
         target_data_order = ELFDATA2LSB;
     }
 
-    if (target_data_order != e_ident[EI_DATA])
-        return -1;
+    if (target_data_order != e_ident[EI_DATA]) {
+        goto fail;
+    }
 
     lseek(fd, 0, SEEK_SET);
     if (e_ident[EI_CLASS] == ELFCLASS64) {
 
     lseek(fd, 0, SEEK_SET);
     if (e_ident[EI_CLASS] == ELFCLASS64) {
This page took 0.028367 seconds and 4 git commands to generate.