commit c6b8f1163708db85251daac24b2ffa6bea24a72a
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Fri Feb 3 22:05:49 2012 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Fri Feb 3 22:05:49 2012 +0000
Fix crash when typing lots of Unicode characters into a number input
box.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2494
---
textscreen/txt_inputbox.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/textscreen/txt_inputbox.c b/textscreen/txt_inputbox.c
index 32704284..d5ad440a 100644
--- a/textscreen/txt_inputbox.c
+++ b/textscreen/txt_inputbox.c
@@ -290,13 +290,14 @@ txt_widget_class_t txt_int_inputbox_class =
TXT_InputBoxFocused,
};
-txt_inputbox_t *TXT_NewInputBox(char **value, int size)
+static txt_inputbox_t *NewInputBox(txt_widget_class_t *widget_class,
+ void *value, int size)
{
txt_inputbox_t *inputbox;
inputbox = malloc(sizeof(txt_inputbox_t));
- TXT_InitWidget(inputbox, &txt_inputbox_class);
+ TXT_InitWidget(inputbox, widget_class);
inputbox->value = value;
inputbox->size = size;
// 'size' is the maximum number of characters that can be entered,
@@ -308,17 +309,13 @@ txt_inputbox_t *TXT_NewInputBox(char **value, int size)
return inputbox;
}
-txt_inputbox_t *TXT_NewIntInputBox(int *value, int size)
+txt_inputbox_t *TXT_NewInputBox(char **value, int size)
{
- txt_inputbox_t *inputbox;
-
- inputbox = malloc(sizeof(txt_inputbox_t));
+ return NewInputBox(&txt_inputbox_class, value, size);
+}
- TXT_InitWidget(inputbox, &txt_int_inputbox_class);
- inputbox->value = value;
- inputbox->size = size;
- inputbox->buffer = malloc(15);
- inputbox->editing = 0;
- return inputbox;
+txt_inputbox_t *TXT_NewIntInputBox(int *value, int size)
+{
+ return NewInputBox(&txt_int_inputbox_class, value, size);
}