summaryrefslogtreecommitdiff
path: root/src/size.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-01-23 16:32:21 -0800
committerUlrich Drepper <drepper@redhat.com>2009-01-23 16:32:21 -0800
commitccccab08d66be13fe9ff5ca07f46709c069b45a2 (patch)
tree81cfc6f4c1eabefffa190d3d54eb59aa36149382 /src/size.c
parent75894321627c15a9dc6c6f0c51dae8ba84802705 (diff)
downloadelfutils-ccccab08d66be13fe9ff5ca07f46709c069b45a2.tar.gz
Fix handling of file descriptors for the files size opens.
Diffstat (limited to 'src/size.c')
-rw-r--r--src/size.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/size.c b/src/size.c
index f6f23d55..4698c350 100644
--- a/src/size.c
+++ b/src/size.c
@@ -319,13 +319,23 @@ process_file (const char *fname)
return 0;
}
else if (likely (elf_kind (elf) == ELF_K_AR))
- return handle_ar (fd, elf, NULL, fname);
+ {
+ int result = handle_ar (fd, elf, NULL, fname);
+
+ if (unlikely (close (fd) != 0))
+ error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
+
+ return result;
+ }
/* We cannot handle this type. Close the descriptor anyway. */
if (unlikely (elf_end (elf) != 0))
INTERNAL_ERROR (fname);
}
+ if (unlikely (close (fd) != 0))
+ error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
+
error (0, 0, gettext ("%s: file format not recognized"), fname);
return 1;
@@ -396,9 +406,6 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname)
if (unlikely (elf_end (elf) != 0))
INTERNAL_ERROR (fname);
- if (unlikely (close (fd) != 0))
- error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname);
-
return result;
}