Avoid undefined behavior in parse_number
authorTom Tromey <tom@tromey.com>
Mon, 30 Jul 2018 02:23:33 +0000 (20:23 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 3 Oct 2018 21:19:06 +0000 (15:19 -0600)
commit20562150d8a894bc91657c843ee88c508188e32e
treeb211b0f74e83b41e417b21e6e9faa905b49acc4e
parentd359392f976d48b04a27e6a09b5b61846b0727f9
Avoid undefined behavior in parse_number

-fsanitize=undefined pointed out that c-exp.y relied on undefined
behavior here:

      if (c != 'l' && c != 'u')
n *= base;

...when a large hex constant "just fit" into a LONGEST, causing the
high bit to be set.

This fixes the problem by having the function work in an unsigned
type.

gdb/ChangeLog
2018-10-03  Tom Tromey  <tom@tromey.com>

* c-exp.y (parse_number): Work in unsigned.  Remove casts.
gdb/ChangeLog
gdb/c-exp.y
This page took 0.029058 seconds and 4 git commands to generate.