shithub: choc

Download patch

ref: c6b8f1163708db85251daac24b2ffa6bea24a72a
parent: 25374dee58942b20a38f446074667e7dbb297b5a
author: Simon Howard <fraggle@gmail.com>
date: Fri Feb 3 17:05:49 EST 2012

Fix crash when typing lots of Unicode characters into a number input
box.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2494

--- a/textscreen/txt_inputbox.c
+++ b/textscreen/txt_inputbox.c
@@ -290,13 +290,14 @@
     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 @@
     return inputbox;
 }
 
-txt_inputbox_t *TXT_NewIntInputBox(int *value, int size)
+txt_inputbox_t *TXT_NewInputBox(char **value, int size)
 {
-    txt_inputbox_t *inputbox;
+    return NewInputBox(&txt_inputbox_class, value, size);
+}
 
-    inputbox = malloc(sizeof(txt_inputbox_t));
-
-    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);
 }