ubsan: s12z: left shift cannot be represented in type 'int'
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 22:07:53 +0000 (08:37 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:10:51 +0000 (11:40 +1030)
* s12z-opc.c (z_decode_signed_value): Avoid signed overflow.

opcodes/ChangeLog
opcodes/s12z-opc.c

index ddf8cd0072489ffcbfc285a0cac4360d21557a93..a8e1d30a9d45b3bc34c6a7d65de72fae4e397d4f 100644 (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.
index 3e0c0e0582ca8c3ff9539b5cfb1f5d28c348f68e..044c72a21cad948b7630e71d0d29fd91ebab1d20 100644 (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)
     {