summaryrefslogtreecommitdiffstats
path: root/libdwfl/open.c
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2009-01-22 12:59:23 -0800
committerRoland McGrath <[email protected]>2009-01-22 12:59:23 -0800
commite34a3f8de4374cd7f73917d28e3ed6e62d5b21f8 (patch)
tree6d2243961e5c18017dceed3a47df0c169ab66e4e /libdwfl/open.c
parent74afbeed7d5d83a4336d8455507bc39ce6dce13c (diff)
Fix build when missing -lz and -lbz2.
Diffstat (limited to 'libdwfl/open.c')
-rw-r--r--libdwfl/open.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libdwfl/open.c b/libdwfl/open.c
index ca6b862f..611295f2 100644
--- a/libdwfl/open.c
+++ b/libdwfl/open.c
@@ -64,14 +64,13 @@
/* Always consumes *ELF, never consumes FD.
Replaces *ELF on success. */
static Dwfl_Error
-decompress (int fd, Elf **elf)
+decompress (int fd __attribute__ ((unused)), Elf **elf)
{
Dwfl_Error error = DWFL_E_BADELF;
+ void *buffer = NULL;
+ size_t size = 0;
#if USE_ZLIB || USE_BZLIB
- void *buffer;
- size_t size;
-
const off64_t offset = (*elf)->start_offset;
void *const mapped = ((*elf)->map_address == NULL ? NULL
: (*elf)->map_address + (*elf)->start_offset);
@@ -87,14 +86,22 @@ decompress (int fd, Elf **elf)
if (error == DWFL_E_NOERROR)
{
- *elf = elf_memory (buffer, size);
- if (*elf == NULL)
+ if (unlikely (size == 0))
{
- error = DWFL_E_LIBELF;
+ error = DWFL_E_BADELF;
free (buffer);
}
else
- (*elf)->flags |= ELF_F_MALLOCED;
+ {
+ *elf = elf_memory (buffer, size);
+ if (*elf == NULL)
+ {
+ error = DWFL_E_LIBELF;
+ free (buffer);
+ }
+ else
+ (*elf)->flags |= ELF_F_MALLOCED;
+ }
}
return error;