aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-04-30 14:04:08 +0100
committerNick Clifton <nickc@redhat.com>2021-04-30 14:04:08 +0100
commit6cb40a679b23b07b9fe0c43147d300b630deec70 (patch)
tree056cbd4d6aa41578d537ccd2ee7b7a82b3d4ba6b /bfd/libbfd.c
parentbfbfa6e7f481aa120aa24f8544c45c685aef3971 (diff)
downloadbinutils-6cb40a679b23b07b9fe0c43147d300b630deec70.zip
binutils-6cb40a679b23b07b9fe0c43147d300b630deec70.tar.gz
binutils-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/libbfd.c')
-rw-r--r--bfd/libbfd.c2
1 files changed, 1 insertions, 1 deletions
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;