Mercurial > hg > early-roguelike
comparison xrogue/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 | e52a8a7ad4c5 |
comparison
equal
deleted
inserted
replaced
| 252:3d4252fa2ed3 | 254:e940e6c00751 |
|---|---|
| 372 len = (char *)sp - str; | 372 len = (char *)sp - str; |
| 373 /* | 373 /* |
| 374 * Look it up and deal with it | 374 * Look it up and deal with it |
| 375 */ | 375 */ |
| 376 for (op = optlist; op < &optlist[NUM_OPTS]; op++) | 376 for (op = optlist; op < &optlist[NUM_OPTS]; op++) |
| 377 { | |
| 377 if (EQSTR(str, op->o_name, len)) | 378 if (EQSTR(str, op->o_name, len)) |
| 378 { | 379 { |
| 379 if (op->o_putfunc == put_bool) /* if option is a boolean */ | 380 if (op->o_putfunc == put_bool) /* if option is a boolean */ |
| 380 *(bool *)op->o_opt = TRUE; | 381 *(bool *)op->o_opt = TRUE; |
| 381 else /* string option */ | 382 else /* string option */ |
| 433 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) | 434 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) |
| 434 { | 435 { |
| 435 *(bool *)op->o_opt = FALSE; | 436 *(bool *)op->o_opt = FALSE; |
| 436 break; | 437 break; |
| 437 } | 438 } |
| 439 } | |
| 438 | 440 |
| 439 /* | 441 /* |
| 440 * skip to start of next option name | 442 * skip to start of next option name |
| 441 */ | 443 */ |
| 442 while (*sp && !isalpha(*sp)) | 444 while (*sp && !isalpha(*sp)) |
