[client] added checking for invalid arguments to custom string options

This commit is contained in:
Geoffrey McRae 2020-01-19 06:48:20 +11:00
parent 4746c89227
commit 2c59b5f557
2 changed files with 11 additions and 2 deletions

View file

@ -1 +1 @@
B1-98-g278d851c7c+1
B1-99-g4746c89227+1

View file

@ -449,6 +449,9 @@ static void doLicense()
static bool optRendererParse(struct Option * opt, const char * str)
{
if (!str)
return false;
if (strcasecmp(str, "auto") == 0)
{
params.forceRenderer = false;
@ -490,6 +493,9 @@ static char * optRendererToString(struct Option * opt)
static bool optPosParse(struct Option * opt, const char * str)
{
if (!str)
return false;
if (strcmp(str, "center") == 0)
{
params.center = true;
@ -527,6 +533,9 @@ static char * optPosToString(struct Option * opt)
static bool optSizeParse(struct Option * opt, const char * str)
{
if (!str)
return false;
if (sscanf(str, "%dx%d", &params.w, &params.h) == 2)
{
if (params.w < 1 || params.h < 1)
@ -558,4 +567,4 @@ static char * optScancodeToString(struct Option * opt)
char * str;
alloc_sprintf(&str, "%d = %s", opt->value.x_int, SDL_GetScancodeName(opt->value.x_int));
return str;
}
}