From 1a0472c5dd71888440b4a835a71b38d0b2b6c7ba Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 4 Nov 2007 15:32:32 +0100 Subject: Added check of buffer pointer in weechat_printf (plugins API) --- src/gui/gui-buffer.c | 4 ++++ src/plugins/plugin-api.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 16afc0133..cb0051574 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -185,6 +185,10 @@ gui_buffer_valid (struct t_gui_buffer *buffer) { struct t_gui_buffer *ptr_buffer; + /* NULL buffer is valid (it's for printing on first buffer) */ + if (!buffer) + return 1; + for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 23b48a76c..6f0ec9e25 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -252,7 +252,8 @@ plugin_api_printf (struct t_weechat_plugin *plugin, va_list argptr; char buf[8192]; - if (!plugin || !format) + if (!plugin || !format + || !gui_buffer_valid ((struct t_gui_buffer *)buffer)) return; va_start (argptr, format); -- cgit v1.2.3