2009-01-22 Roland McGrath <roland@redhat.com>
+ * open.c (decompress): Move BUFFER, SIZE decls outside #if.
+
* dwfl_segment_report_module.c (addr_segndx): Remove bogus adjustments
after address-matching loop.
/* 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);
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;