1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

core: fix bugs with calls to realloc

This commit is contained in:
Sebastien Helleu
2011-08-28 15:25:30 +02:00
parent e411d14b7a
commit f843f904bc
16 changed files with 259 additions and 106 deletions
+12 -2
View File
@@ -1323,7 +1323,7 @@ gui_key_free_all (struct t_gui_key **keys, struct t_gui_key **last_key,
void
gui_key_buffer_optimize ()
{
int optimal_size;
int optimal_size, *gui_key_buffer2;
optimal_size = (((gui_key_buffer_size * sizeof (int)) /
GUI_KEY_BUFFER_BLOCK_SIZE) *
@@ -1333,7 +1333,17 @@ gui_key_buffer_optimize ()
if (gui_key_buffer_alloc != optimal_size)
{
gui_key_buffer_alloc = optimal_size;
gui_key_buffer = realloc (gui_key_buffer, optimal_size);
gui_key_buffer2 = realloc (gui_key_buffer, optimal_size);
if (!gui_key_buffer2)
{
if (gui_key_buffer)
{
free (gui_key_buffer);
gui_key_buffer = NULL;
}
return;
}
gui_key_buffer = gui_key_buffer2;
}
}