diff options
author | Nick Clifton <nickc@redhat.com> | 2021-04-30 14:04:08 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-04-30 14:04:08 +0100 |
commit | 6cb40a679b23b07b9fe0c43147d300b630deec70 (patch) | |
tree | 056cbd4d6aa41578d537ccd2ee7b7a82b3d4ba6b /bfd | |
parent | bfbfa6e7f481aa120aa24f8544c45c685aef3971 (diff) | |
download | gdb-6cb40a679b23b07b9fe0c43147d300b630deec70.zip gdb-6cb40a679b23b07b9fe0c43147d300b630deec70.tar.gz gdb-6cb40a679b23b07b9fe0c43147d300b630deec70.tar.bz2 |
Fix a double free when re-allocating a buffer to size 0.
PR 27797
* libbfd.c (bfd_realloc_or_free): Do not free a pointer than has
been realloc'ed to size 0.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/libbfd.c | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index cd904da..548ed9f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2021-04-30 Nick Clifton <nickc@redhat.com> + PR 27797 + * libbfd.c (bfd_realloc_or_free): Do not free a pointer than has + been realloc'ed to size 0. + +2021-04-30 Nick Clifton <nickc@redhat.com> + PR 27795 * coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Check for invalid name lengths. diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 9db14c3..52c9245 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -312,7 +312,7 @@ bfd_realloc_or_free (void *ptr, bfd_size_type size) { void *ret = bfd_realloc (ptr, size); - if (ret == NULL) + if (ret == NULL && size > 0) free (ptr); return ret; |