From: H.G.Muller Date: Sat, 24 Dec 2016 18:41:11 +0000 (+0100) Subject: Fix string options with empty default X-Git-Tag: v4.0~39 X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=commitdiff_plain;h=142b07fac63966ef4e12a5ae0d1d7875905a8764 Fix string options with empty default When sscanf finds nothing after 'default', it does not touch the target array at all, rather than putting an empty string in it. So the target is now initialized to an empty string before the sscanf. --- diff --git a/UCI2WB.c b/UCI2WB.c index cbc11f7..6b4d19d 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -332,7 +332,7 @@ Engine2GUI() } else if(!strcmp(command, "option")) { // USI option: extract data fields char name[80], type[80], buf[1024], val[256], *q; - int min=0, max=1e9; + int min=0, max=1e9; *val = 0; if(p = strstr(line+6, " type ")) sscanf(p+1, "type %s", type), *p = '\n'; if(p = strstr(line+6, " min ")) sscanf(p+1, "min %d", &min), *p = '\n'; if(p = strstr(line+6, " max ")) sscanf(p+1, "max %d", &max), *p = '\n';