diff options
-rw-r--r-- | source3/utils/regedit_dialog.c | 2 | ||||
-rw-r--r-- | source3/utils/regedit_hexedit.c | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c index 08b746b5f7..d05efad142 100644 --- a/source3/utils/regedit_dialog.c +++ b/source3/utils/regedit_dialog.c @@ -1027,8 +1027,10 @@ static WERROR handle_editor_input(struct edit_dialog *edit, "Enter new size"); if (n) { newlen = strtoul(n, NULL, 10); + edit->section = IN_DATA; hexedit_resize_buffer(edit->buf, newlen); hexedit_refresh(edit->buf); + hexedit_set_cursor(edit->buf); talloc_free(n); } } else if (selection == DIALOG_CANCEL) { diff --git a/source3/utils/regedit_hexedit.c b/source3/utils/regedit_hexedit.c index e2864e3fae..8f1c2c72f8 100644 --- a/source3/utils/regedit_hexedit.c +++ b/source3/utils/regedit_hexedit.c @@ -93,8 +93,12 @@ static size_t bytes_per_screen(WINDOW *win) void hexedit_set_cursor(struct hexedit *buf) { werase(buf->status_line); - wprintw(buf->status_line, "Len:%lu Off:%lu Val:0x%X", buf->len, - buf->cursor_offset, buf->data[buf->cursor_offset]); + if (buf->len) { + wprintw(buf->status_line, "Len:%lu Off:%lu Val:0x%X", buf->len, + buf->cursor_offset, buf->data[buf->cursor_offset]); + } else { + wprintw(buf->status_line, "Len:%lu (empty)", buf->len); + } wmove(buf->win, buf->cursor_y, buf->cursor_x); wcursyncup(buf->win); wsyncup(buf->win); @@ -108,6 +112,10 @@ void hexedit_refresh(struct hexedit *buf) size_t off; werase(buf->win); + if (buf->len == 0) { + mvwprintw(buf->win, 0, 0, "%08X", 0); + return; + } end = buf->offset + bytes_per_screen(buf->win); if (end > buf->len) { @@ -294,6 +302,9 @@ static void cursor_right(struct hexedit *buf) { int new_x = buf->cursor_x + 1; + if (buf->len == 0) { + return; + } if (new_x == ASCII_COL_END) { return; } @@ -335,6 +346,10 @@ static void do_edit(struct hexedit *buf, int c) { uint8_t *byte; + if (buf->len == 0) { + return; + } + byte = buf->data + buf->cursor_offset; if (buf->cursor_x >= ASCII_COL) { |