From: Arun Persaud Date: Tue, 6 Oct 2009 04:01:32 +0000 (-0700) Subject: bugfix: segfault when invalid option argument was given (bug #27427) X-Git-Tag: v4.4.1.20091019~52 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=f9fe58c6ea5c0938364cd9bd0b434ee66e0f7272 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. --- 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)