gresource-tool: Fix an FD leak in an error path
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 15 May 2014 09:18:38 +0000 (10:18 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 15 May 2014 13:35:19 +0000 (14:35 +0100)
Coverity issues: #1214054, #1214055, #1214056

gio/gresource-tool.c

index f751f50..634a83a 100644 (file)
@@ -151,10 +151,18 @@ get_elf (const gchar *file,
 
   elf = elf_begin (*fd, ELF_C_READ, NULL);
   if (elf == NULL)
-    return NULL;
+    {
+      g_close (*fd, NULL);
+      *fd = -1;
+      return NULL;
+    }
 
   if (elf_kind (elf) != ELF_K_ELF)
-    return NULL;
+    {
+      g_close (*fd, NULL);
+      *fd = -1;
+      return NULL;
+    }
 
   return elf;
 }