From ebb17864920d1b15f3c392ce5cd22ddee169e825 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 15 May 2021 14:37:42 +0930 Subject: [PATCH] SAFE_BYTE_GET_INTERNAL We won't want this assert triggering in the next release. * dwarf.c (SAFE_BYTE_GET_INTERNAL): Assert only when ENABLE_CHECKING. --- binutils/ChangeLog | 4 ++++ binutils/dwarf.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 74efc3376eb..691fdfcb704 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2021-05-15 Alan Modra + + * dwarf.c (SAFE_BYTE_GET_INTERNAL): Assert only when ENABLE_CHECKING. + 2021-05-15 Alan Modra * bucomm.h (_mul_overflow): Define. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 020b7e071ec..3a1c18e082f 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -390,8 +390,11 @@ read_leb128 (unsigned char *data, (int) amount, (int) sizeof (VAL)); \ amount = sizeof (VAL); \ } \ - assert ((PTR) <= (END)); \ + if (ENABLE_CHECKING) \ + assert ((PTR) <= (END)); \ size_t avail = (END) - (PTR); \ + if ((PTR) > (END)) \ + avail = 0; \ if (amount > avail) \ amount = avail; \ if (amount == 0) \ -- 2.30.2