From 0110f81e8896c7a1f57d3f62f190f6dd7d87fe90 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 22 Feb 2014 12:07:43 +0100 Subject: [PATCH] core: fix potential NULL pointer in function gui_color_emphasize --- ChangeLog | 1 + src/gui/gui-color.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index eac059a01..10b859aed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.4 (under dev) +* core: fix potential NULL pointer in function gui_color_emphasize * core: use same return code and message in all commands when arguments are wrong/missing * core: add option "-beep" in command /print diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 0971f6d76..13b4ea8ff 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -615,7 +615,12 @@ gui_color_emphasize (const char *string, int rc, length_search, length_emphasis, length_result; int pos1, pos2, real_pos1, real_pos2, count_emphasis; - if (!string && !regex) + /* string is required */ + if (!string) + return NULL; + + /* search or regex is required */ + if (!search && !regex) return NULL; color_emphasis = gui_color_get_custom ("emphasis");