ubsan: s12z: left shift cannot be represented in type 'int'

* s12z-opc.c (z_decode_signed_value): Avoid signed overflow.
This commit is contained in:
Alan Modra 2019-12-11 08:37:53 +10:30
parent fb4cb4e26d
commit 205c426a9b
2 changed files with 5 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2019-12-11 Alan Modra <amodra@gmail.com>
* s12z-opc.c (z_decode_signed_value): Avoid signed overflow.
2019-12-11 Alan Modra <amodra@gmail.com>
* ns32k-dis.c (bit_extract): Use unsigned arithmetic.

View File

@ -410,9 +410,7 @@ z_decode_signed_value (struct mem_read_abstraction_base *mra, int offset,
int i;
uint32_t value = 0;
for (i = 0; i < size; ++i)
{
value |= buffer[i] << (8 * (size - i - 1));
}
value = (value << 8) | buffer[i];
if (buffer[0] & 0x80)
{