Mercurial > hg > early-roguelike
comparison arogue5/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 |
---|---|
375 len = (int)(sp - str); | 375 len = (int)(sp - str); |
376 /* | 376 /* |
377 * Look it up and deal with it | 377 * Look it up and deal with it |
378 */ | 378 */ |
379 for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) | 379 for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++) |
380 { | |
380 /* None of these can be changed if using system savefiles. */ | 381 /* None of these can be changed if using system savefiles. */ |
381 if (use_savedir && (!strcmp(op->o_name, "name") || | 382 if (use_savedir && (!strcmp(op->o_name, "name") || |
382 !strcmp(op->o_name, "file") || | 383 !strcmp(op->o_name, "file") || |
383 !strcmp(op->o_name, "score") )) | 384 !strcmp(op->o_name, "score") )) |
384 continue; | 385 continue; |
440 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) | 441 && EQSTR(str, "no", 2) && EQSTR(str + 2, op->o_name, len - 2)) |
441 { | 442 { |
442 *(bool *)op->o_opt = FALSE; | 443 *(bool *)op->o_opt = FALSE; |
443 break; | 444 break; |
444 } | 445 } |
446 } | |
445 | 447 |
446 /* | 448 /* |
447 * skip to start of next option name | 449 * skip to start of next option name |
448 */ | 450 */ |
449 while (*sp && !isalpha(*sp)) | 451 while (*sp && !isalpha(*sp)) |