summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2012-02-03 22:05:49 +0000
committerSimon Howard2012-02-03 22:05:49 +0000
commitc6b8f1163708db85251daac24b2ffa6bea24a72a (patch)
tree506a8410ab0db6904862a69121f9f99c7fc0f1bb
parent25374dee58942b20a38f446074667e7dbb297b5a (diff)
downloadchocolate-doom-c6b8f1163708db85251daac24b2ffa6bea24a72a.tar.gz
chocolate-doom-c6b8f1163708db85251daac24b2ffa6bea24a72a.tar.bz2
chocolate-doom-c6b8f1163708db85251daac24b2ffa6bea24a72a.zip
Fix crash when typing lots of Unicode characters into a number input
box. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2494
-rw-r--r--textscreen/txt_inputbox.c21
1 files 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);
}