cp-demangle.c (d_number): Avoid signed int overflow.
authorPaul Pluzhnikov <ppluzhnikov@google.com>
Tue, 29 Oct 2019 15:29:59 +0000 (08:29 -0700)
committerPaul Pluzhnikov <ppluzhnikov@gcc.gnu.org>
Tue, 29 Oct 2019 15:29:59 +0000 (08:29 -0700)
2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>

* cp-demangle.c (d_number): Avoid signed int overflow.

From-SVN: r277575

libiberty/ChangeLog
libiberty/cp-demangle.c

index bba2be8b81bed0afea5197fbb1d583bfc685d6a8..4992b15d681a470548d1509fa466c5ccd6993f0d 100644 (file)
@@ -1,3 +1,7 @@
+2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+       * cp-demangle.c (d_number): Avoid signed int overflow.
+
 2019-10-28  Miguel Saldivar  <saldivarcher@gmail.com>
 
        * cp-demangle.c (d_print_mod): Add a space before printing `complex`
index 877ad359be115b716a8467f1d1d4aa8f23971c2b..5b674d7d93c4612723c9580c05ee7806d774d16c 100644 (file)
@@ -1717,7 +1717,7 @@ d_number (struct d_info *di)
        }
       if (ret > ((INT_MAX - (peek - '0')) / 10))
         return -1;
-      ret = ret * 10 + peek - '0';
+      ret = ret * 10 + (peek - '0');
       d_advance (di, 1);
       peek = d_peek_char (di);
     }