mmap: Fix a memory leak in _bfd_mmap_read_temporary

Return malloced memory in *mmap_base so that _bfd_munmap_readonly_temporary
will free it.

	* libbfd.c (_bfd_mmap_read_temporary): Return malloced memory
	in *mmap_base.
This commit is contained in:
H.J. Lu 2024-04-09 16:02:48 -07:00
parent c3460201a6
commit 533da9536e

View File

@ -1223,7 +1223,11 @@ _bfd_mmap_read_temporary (void **data_p, size_t *size_p,
if (data == NULL)
return false;
*data_p = data;
/* NB: _bfd_munmap_readonly_temporary will free *MMAP_BASE if
*SIZE_P == 0. */
*mmap_base = data;
}
else
*mmap_base = NULL;
*size_p = 0;
return bfd_read (data, size, abfd) == size;