summaryrefslogtreecommitdiff
path: root/src/gui/gui-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui-input.c')
-rw-r--r--src/gui/gui-input.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index e8cfb0a70..0eab02e4f 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -59,6 +59,7 @@ void
gui_input_optimize_size (struct t_gui_buffer *buffer)
{
int optimal_size;
+ char *input_buffer2;
if (buffer->input)
{
@@ -67,7 +68,17 @@ gui_input_optimize_size (struct t_gui_buffer *buffer)
if (buffer->input_buffer_alloc != optimal_size)
{
buffer->input_buffer_alloc = optimal_size;
- buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
+ input_buffer2 = realloc (buffer->input_buffer, optimal_size);
+ if (!input_buffer2)
+ {
+ if (buffer->input_buffer)
+ {
+ free (buffer->input_buffer);
+ buffer->input_buffer = NULL;
+ }
+ return;
+ }
+ buffer->input_buffer = input_buffer2;
}
}
}