Mercurial > hg > early-roguelike
comparison arogue7/options.c @ 254:e940e6c00751
Add some braces to a loop in parse_opts().
A for loop had no braces around its body, which was a single if-else
statement. In Advanced Rogue 5, another statement had been added,
accidentally removing the if-else from the loop. This could have
resulted in an out-of-bounds access to the options array.
In the other games, the added braces are only for clarity.
| author | John "Elwin" Edwards |
|---|---|
| date | Fri, 10 Feb 2017 09:02:58 -0500 |
| parents | 50b89f165a34 |
| children | d3968e9cb98d |
comparison
equal
deleted
inserted
replaced
| 252:3d4252fa2ed3 | 254:e940e6c00751 |
|---|---|
| 348 len = (int)(sp - str); | 348 len = (int)(sp - str); |
| 349 /* | 349 /* |
| 350 * Look it up and deal with it | 350 * Look it up and deal with it |
| 351 */ | 351 */ |
| 352 for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) | 352 for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) |
| 353 { | |
| 353 if (EQSTR(str, op->o_name, len)) | 354 if (EQSTR(str, op->o_name, len)) |
| 354 { | 355 { |
| 355 if (op->o_putfunc == put_bool) /* if option is a boolean */ | 356 if (op->o_putfunc == put_bool) /* if option is a boolean */ |
| 356 *(bool *)op->o_opt = TRUE; | 357 *(bool *)op->o_opt = TRUE; |
| 357 else /* string option */ | 358 else /* string option */ |
| 410 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) | 411 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) |
| 411 { | 412 { |
| 412 *(bool *)op->o_opt = FALSE; | 413 *(bool *)op->o_opt = FALSE; |
| 413 break; | 414 break; |
| 414 } | 415 } |
| 416 } | |
| 415 | 417 |
| 416 /* | 418 /* |
| 417 * skip to start of next option name | 419 * skip to start of next option name |
| 418 */ | 420 */ |
| 419 while (*sp && !isalpha(*sp)) | 421 while (*sp && !isalpha(*sp)) |
