Prevent crash on help-click for engine without manual
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 29 Apr 2016 14:16:52 +0000 (16:16 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 8 May 2016 12:06:34 +0000 (14:06 +0200)
The error message of "man w xxx" when no man entry for xxx exists
appears on stderr, which is not caught by popen(). As a result the
path to the man file gets set to an empty string, and saveStrCpy
is not so save that it can copy an empty string, but quits XBoard
through an ASSERT in that case.

dialogs.c

index d3b333e..9b48704 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -2691,7 +2691,9 @@ DisplayHelp (char *name)
            FREE(manText[1]); manText[1] = NULL;      // so any currently held text is worthless
            safeStrCpy(tidy, buf, MSG_SIZ);           // remember current engine
            eng = BufferCommandOutput(tidy, MSG_SIZ); // obtain path to  its man file
+           if(*eng)
            safeStrCpy(engMan, eng, strlen(eng));     // and remember that too
+           else *engMan = NULLCHAR;
            FREE(eng);
        }
        safeStrCpy(buf, engMan, MSG_SIZ); n = 1;      // use engine man