From a79a38d1732331e3920ee06fde662fa0f4bc1405 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 22 Sep 2014 20:39:21 +0200 Subject: [PATCH] Prevent crash on specifying non-existent texture XB By setting the texture width to 0 when the texture could not be loaded, XBoard will never attempt to draw it. --- dialogs.c | 10 +++++++++- draw.c | 1 + 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/dialogs.c b/dialogs.c index 83574f7..e02bc17 100644 --- a/dialogs.c +++ b/dialogs.c @@ -577,11 +577,17 @@ NewVariantProc () //------------------------------------------- Common Engine Options ------------------------------------- static int oldCores; +static char *egtPath; static int CommonOptionsOK (int n) { int newPonder = appData.ponderNextMove; + if(*egtPath != '/' && strchr(egtPath, ':')) { + ASSIGN(appData.egtFormats, egtPath); + } else { + ASSIGN(appData.defaultPathEGTB, egtPath); + } // make sure changes are sent to first engine by re-initializing it // if it was already started pre-emptively at end of previous game if(gameMode == BeginningOfGame) Reset(True, True); else { @@ -599,7 +605,7 @@ static Option commonEngineOptions[] = { { 0, 0, 1000, NULL, (void*) &appData.smpCores, "", NULL, Spin, N_("Maximum Number of CPUs per Engine:") }, { 0, 0, 0, NULL, (void*) &appData.polyglotDir, "", NULL, PathName, N_("Polygot Directory:") }, { 0, 0,16000, NULL, (void*) &appData.defaultHashSize, "", NULL, Spin, N_("Hash-Table Size (MB):") }, -{ 0, 0, 0, NULL, (void*) &appData.defaultPathEGTB, "", NULL, PathName, N_("Nalimov EGTB Path:") }, +{ 0, 0, 0, NULL, (void*) &egtPath, "", NULL, PathName, N_("EGTB Path:") }, { 0, 0, 1000, NULL, (void*) &appData.defaultCacheSizeEGTB, "", NULL, Spin, N_("EGTB Cache Size (MB):") }, { 0, 0, 0, NULL, (void*) &appData.usePolyglotBook, "", NULL, CheckBox, N_("Use GUI Book") }, { 0, 0, 0, NULL, (void*) &appData.polyglotBook, ".bin", NULL, FileName, N_("Opening-Book Filename:") }, @@ -615,6 +621,8 @@ UciMenuProc () { oldCores = appData.smpCores; oldPonder = appData.ponderNextMove; + if(appData.egtFormats && *appData.egtFormats) { ASSIGN(egtPath, appData.egtFormats); } + else { ASSIGN(egtPath, appData.defaultPathEGTB); } GenericPopUp(commonEngineOptions, _("Common Engine Settings"), TransientDlg, BoardWindow, MODAL, 0); } diff --git a/draw.c b/draw.c index c45723c..d0b3eda 100644 --- a/draw.c +++ b/draw.c @@ -241,6 +241,7 @@ CreatePNGBoard (char *s, int kind) float w, h; static float n[2] = { 1., 1. }; if(!appData.useBitmaps || s == NULL || *s == 0 || *s == '*') { useTexture &= ~(kind+1); return; } + textureW[kind] = 0; // prevents bitmap from being used if not succesfully loaded if(strstr(s, ".png")) { cairo_surface_t *img = cairo_image_surface_create_from_png (s); if(img) { -- 1.7.0.4