From 4418fd03bf26086c8c7bd9bd14d3c4ee06bf9373 Mon Sep 17 00:00:00 2001 From: Byrial Jensen Date: Sun, 18 Dec 2011 17:24:07 +0100 Subject: [PATCH] Duh! Initialise the argument to sscanf() inside the loop, so it always gets a known value when sscanf() fails. --- xoptions.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) 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; -- 1.7.0.4