Skip to content

Commit

Permalink
dbg: do not allow inserting too long text when editing registers
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Dec 7, 2019
1 parent a299847 commit 3cf3ca8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion emu/src/dbg/uisupport.rs
Expand Up @@ -99,7 +99,14 @@ pub fn imgui_input_hex<T: HexableInt>(

let iw = ui.push_item_width(T::HEX_DIGITS as f32 * 7.0 + 8.0);

let mut spc = ImString::new(val.format());
let vals = val.format();

// Create a buffer with the exact capacity needed to store this number.
// This blocks Imgui from letting the user put more digits than allowed.
let mut spc = ImString::with_capacity(vals.len());
spc.push_str(&vals);

// Draw the input text
if ui
.input_text(name, &mut spc)
.chars_hexadecimal(true)
Expand Down

0 comments on commit 3cf3ca8

Please sign in to comment.