From c86de122f91cff5df6ac35cdb12d24e5f1fb37a9 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 18 May 2014 21:31:40 +0200 Subject: [PATCH] WINGs: do not crash on NULL title in WMSetWindowTitle (Coverity #50046) As pointed by Coverity, despite apparent checks the function would fail if trying to set a NULL title. Instead of trying to do over-complicated things we just ignore (with a warning if NDEBUG is not set) the case. If user wants an empty title, the correct way is to provide "" as we're not able to remove a title. Signed-off-by: Christophe CURIS --- WINGs/wwindow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index e600f89e..5293f87b 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -255,12 +255,12 @@ static void setMiniwindow(WMWindow *win, RImage *image) void WMSetWindowTitle(WMWindow * win, const char *title) { + wassertr(title != NULL); + if (win->title != NULL) wfree(win->title); - if (title != NULL) - win->title = wstrdup(title); - else - win->title = NULL; + + win->title = wstrdup(title); if (win->view->flags.realized) { setWindowTitle(win, title);