From f9fe58c6ea5c0938364cd9bd0b434ee66e0f7272 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 5 Oct 2009 21:01:32 -0700 Subject: [PATCH] bugfix: segfault when invalid option argument was given (bug #27427) when given a wrong argument to an option (e.g. -tc 0) xboard aborts before setting up the window, but tried to write a message to the messageWidget which doesn't exist at that point. --- xboard.c | 41 ++++++++++++++++++++++++++++------------- 1 files changed, 28 insertions(+), 13 deletions(-) diff --git a/xboard.c b/xboard.c index 0e8b132..e8b561d 100644 --- a/xboard.c +++ b/xboard.c @@ -7641,19 +7641,34 @@ void Iconify(w, event, prms, nprms) void DisplayMessage(message, extMessage) char *message, *extMessage; { - char buf[MSG_SIZ]; - Arg arg; - - if (extMessage) { - if (*message) { - snprintf(buf, sizeof(buf), "%s %s", message, extMessage); - message = buf; - } else { - message = extMessage; - } - } - XtSetArg(arg, XtNlabel, message); - XtSetValues(messageWidget, &arg, 1); + /* display a message in the message widget */ + + char buf[MSG_SIZ]; + Arg arg; + + if (extMessage) + { + if (*message) + { + snprintf(buf, sizeof(buf), "%s %s", message, extMessage); + message = buf; + } + else + { + message = extMessage; + }; + }; + + /* need to test if messageWidget already exists, since this function + can also be called during the startup, if for example a Xresource + is not set up correctly */ + if(messageWidget) + { + XtSetArg(arg, XtNlabel, message); + XtSetValues(messageWidget, &arg, 1); + }; + + return; } void DisplayTitle(text) -- 1.7.0.4