From e34a3f8de4374cd7f73917d28e3ed6e62d5b21f8 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 22 Jan 2009 12:59:23 -0800 Subject: [PATCH] Fix build when missing -lz and -lbz2. --- libdwfl/ChangeLog | 2 ++ libdwfl/open.c | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 87e2b48d7..5490f5f0f 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,5 +1,7 @@ 2009-01-22 Roland McGrath + * open.c (decompress): Move BUFFER, SIZE decls outside #if. + * dwfl_segment_report_module.c (addr_segndx): Remove bogus adjustments after address-matching loop. diff --git a/libdwfl/open.c b/libdwfl/open.c index ca6b862fa..611295f2a 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; -- 2.47.2