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.
This commit is contained in:
Nick Clifton 2021-04-30 14:04:08 +01:00
parent bfbfa6e7f4
commit 6cb40a679b
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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;