From: Byrial Jensen Date: Sun, 18 Dec 2011 16:24:07 +0000 (+0100) Subject: Duh! Initialise the argument to sscanf() inside the loop, so it always gets a known... X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=4418fd03bf26086c8c7bd9bd14d3c4ee06bf9373;p=xboard.git Duh! Initialise the argument to sscanf() inside the loop, so it always gets a known value when sscanf() fails. --- diff --git a/xoptions.c b/xoptions.c index 8cc231a..926f905 100644 --- a/xoptions.c +++ b/xoptions.c @@ -813,7 +813,7 @@ int GenericReadout(int selected) String val; Arg args[16]; char buf[MSG_SIZ], **dest; - float x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered + float x; for(i=0; ; i++) { // send all options that had to be OK-ed to engine if(selected >= 0) { if(i < selected) continue; else if(i > selected) break; } switch(currentOption[i].type) { @@ -838,6 +838,7 @@ int GenericReadout(int selected) case Fractional: XtSetArg(args[0], XtNstring, &val); XtGetValues(currentOption[i].handle, args, 1); + x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered sscanf(val, "%f", &x); if(x > currentOption[i].max) x = currentOption[i].max; if(x < currentOption[i].min) x = currentOption[i].min;