gdb: fix off-by-one error in quirk_rust_enum
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 19 May 2020 18:20:23 +0000 (14:20 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 19 May 2020 18:20:23 +0000 (14:20 -0400)
commitf408d82c7a140268c3b7be35970c96d8385b5902
tree7920efab8daf34e13bd9ddc8cce9c3d105935b0f
parent98c59b527b1472b87a9ee4959c4bfae85061bc1d
gdb: fix off-by-one error in quirk_rust_enum

Found by inspection, so I don't have a test for it (I don't think it
would be easy to have this bug cause a failure reliably).

We allocate space for N fields into `new_fields`, then memcpy N fields
at `new_fields + 1`.  This overflows the allocated buffer by one field.

Fix it by allocating `N + 1` fields.

gdb/ChangeLog:

* dwarf2/read.c (quirk_rust_enum): Allocate enough fields.
gdb/ChangeLog
gdb/dwarf2/read.c