aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/objcopy.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 7eb9009..ff1e52c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2020-06-03 Alan Modra <amodra@gmail.com>
+
+ PR 26069
+ * objcopy.c (copy_relocations_in_section): Free relpp on error.
+ Don't accidentally free isection->orelocation.
+
2020-06-02 Alan Modra <amodra@gmail.com>
* testsuite/binutils-all/ar.exp (obj): Set up object file name
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 5760d06..3866c7f 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4294,6 +4294,7 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
status = 1;
bfd_nonfatal_message (NULL, ibfd, isection,
_("relocation count is negative"));
+ free (relpp);
return;
}
}
@@ -4318,7 +4319,7 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
temp_relpp [temp_relcount++] = relpp [i];
}
relcount = temp_relcount;
- if (isection->orelocation == NULL)
+ if (relpp != isection->orelocation)
free (relpp);
relpp = temp_relpp;
}
@@ -4327,7 +4328,8 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
if (relcount == 0)
{
osection->flags &= ~SEC_RELOC;
- free (relpp);
+ if (relpp != isection->orelocation)
+ free (relpp);
}
}
}