X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libelf%2Felf_end.c;h=fde17b5018a1c79fc8be8e9de96c0e7e7e79c267;hb=82c3b58b54026d061a4d81ad95f3023d5d883ab2;hp=d4ae051755c3825b948a8a957cf0cf19b9bf1d2d;hpb=a286dd013ef8d46edf013efc0908822a59d8ac81;p=platform%2Fupstream%2Felfutils.git diff --git a/libelf/elf_end.c b/libelf/elf_end.c index d4ae051..fde17b5 100644 --- a/libelf/elf_end.c +++ b/libelf/elf_end.c @@ -1,5 +1,5 @@ /* Free resources associated with Elf descriptor. - Copyright (C) 1998,1999,2000,2001,2002,2004,2005,2007 Red Hat, Inc. + Copyright (C) 1998,1999,2000,2001,2002,2004,2005,2007,2015 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1998. @@ -40,8 +40,7 @@ int -elf_end (elf) - Elf *elf; +elf_end (Elf *elf) { Elf *parent; @@ -151,6 +150,12 @@ elf_end (elf) /* It doesn't matter which pointer. */ free (scn->shdr.e32); + /* Free zdata if uncompressed, but not yet used as + rawdata_base. If it is already used it will be + freed below. */ + if (scn->zdata_base != scn->rawdata_base) + free (scn->zdata_base); + /* If the file has the same byte order and the architecture doesn't require overly stringent alignment the raw data buffer is the same as the @@ -159,8 +164,9 @@ elf_end (elf) free (scn->data_base); /* The section data is allocated if we couldn't mmap - the file. */ - if (elf->map_address == NULL) + the file. Or if we had to decompress. */ + if (elf->map_address == NULL + || scn->rawdata_base == scn->zdata_base) free (scn->rawdata_base); /* Free the list of data buffers for the section.