From ec5a5fd73f287a67d09e89618595bbdba8cb18fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 15 Aug 2018 16:24:07 +0200 Subject: core: fix use of NULL pointer in command /buffer when the GUI is not yet initialized --- src/core/wee-command.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/wee-command.c b/src/core/wee-command.c index c76f4be92..7bacb73d5 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1192,9 +1192,10 @@ COMMAND_CALLBACK(buffer) if (!ptr_buffer->hidden) break; } - gui_buffer_switch_by_number (gui_current_window, - (ptr_buffer) ? - ptr_buffer->number : gui_buffers->number); + number = (ptr_buffer) ? + ptr_buffer->number : ((gui_buffers) ? gui_buffers->number : -1); + if (number > 0) + gui_buffer_switch_by_number (gui_current_window, number); } else { @@ -1261,9 +1262,10 @@ COMMAND_CALLBACK(buffer) if (!ptr_buffer->hidden) break; } - gui_buffer_switch_by_number (gui_current_window, - (ptr_buffer) ? - ptr_buffer->number : last_gui_buffer->number); + number = (ptr_buffer) ? + ptr_buffer->number : ((last_gui_buffer) ? last_gui_buffer->number : -1); + if (number > 0) + gui_buffer_switch_by_number (gui_current_window, number); } else { -- cgit v1.2.3