Skip to content

Commit e9cf369

Browse files
committed
PR26741, benign use after free in riscv_parse_prefixed_ext
ISO/IEC 9899:1999 C standard "J.2 Undefined behavior" says the following is undefined behaviour: "The value of a pointer that refers to space deallocated by a call to the free or realloc function is used (7.20.3)." PR 26741 * elfxx-riscv.c (riscv_parse_prefixed_ext): Free subset after calculating subset version length.
1 parent a7c23ac commit e9cf369

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

bfd/ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2021-01-04 Alan Modra <[email protected]>
2+
3+
PR 26741
4+
* elfxx-riscv.c (riscv_parse_prefixed_ext): Free subset after
5+
calculating subset version length.
6+
17
2021-01-01 Nicolas Boulenguez <[email protected]>
28

39
* xcofflink.c: Correct spelling in comments.

bfd/elfxx-riscv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ riscv_parse_prefixed_ext (riscv_parse_subset_t *rps,
15721572
riscv_parse_add_subset (rps, subset,
15731573
major_version,
15741574
minor_version, FALSE);
1575-
free (subset);
15761575
p += end_of_version - subset;
1576+
free (subset);
15771577

15781578
if (*p != '\0' && *p != '_')
15791579
{

0 commit comments

Comments
 (0)