From 8d1a606a1260f32e1e49b3d1d4f35c51b7dc8742 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 15 Dec 2021 15:08:09 +0300 Subject: widget/input: copy the define text to the buffer --- Library/UefiShellUfmCommandLib/widget/input.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/UefiShellUfmCommandLib/widget/input.c b/Library/UefiShellUfmCommandLib/widget/input.c index 7531321..3fbb1b2 100644 --- a/Library/UefiShellUfmCommandLib/widget/input.c +++ b/Library/UefiShellUfmCommandLib/widget/input.c @@ -8,6 +8,7 @@ struct widget_input *input_alloc(struct screen *scr, INT32 x, INT32 y, INT32 width, INT32 attr, CONST CHAR16 *def_text) { struct widget_input *in; + UINTN text_length; ASSERT(scr != NULL); @@ -24,10 +25,11 @@ struct widget_input *input_alloc(struct screen *scr, INT32 x, INT32 y, whline(in->win, 0, 0, 0, attr, 0); mvwprintf(in->win, 0, 0, def_text); - in->point = 0; + text_length = StrLen(def_text); + in->point = text_length > width ? width : text_length; in->max_size = width; - in->buf_len = 0; - in->buffer = AllocateZeroPool((in->max_size + 1) * sizeof(CHAR16)); + in->buf_len = in->point; + in->buffer = AllocateCopyPool((in->max_size + 1) * sizeof(CHAR16), def_text); if(!in->buffer) { input_release(in); return NULL; -- cgit v1.2.3-18-g5258