diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-04-09 16:02:48 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-04-10 19:51:29 -0700 |
commit | 533da9536e6e4d65f0623ede93365f7229779f54 (patch) | |
tree | d0e3849981fb05fab6f0dfcb3d151483ff5d1f3a /bfd | |
parent | c3460201a64b641e3a2089b7fca7ae17a9ddfb85 (diff) | |
download | gdb-533da9536e6e4d65f0623ede93365f7229779f54.zip gdb-533da9536e6e4d65f0623ede93365f7229779f54.tar.gz gdb-533da9536e6e4d65f0623ede93365f7229779f54.tar.bz2 |
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/libbfd.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c index e92ed5e..2f5ddca 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1223,8 +1223,12 @@ _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; } - *mmap_base = NULL; + else + *mmap_base = NULL; *size_p = 0; return bfd_read (data, size, abfd) == size; } |