libelf: Free and clear rawdata_base and zdata_base consistently

There could be a leak if a program called elf_strptr on a compressed
section, but the program never requests the (uncompressed) section data,
but does explicitly (re)compress that same section data.

Fix this by explicitly always freeing and clearing the zdata_base
and rawdata_base in __libelf_reset_rawdata and elf_compress. Also
clear zdata_base in elf_end so the pointer isn't indeterminate when
it is being used in a later comparison against rawdata_base.

	* libelf/elf_compress.c (elf_compress): Explicitly free
	zdata_base before clearing.
	(__libelf_reset_rawdata): Free zdata_base if it isn't
	(going to be) used for rawdata_base. Explicitly clear
	rawdata_base and zdata_base after free.
	* libelf/elf_end.c (elf_end): Clear zdata_base after free.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 files changed