Fix getpath() not to crash when path exceeds MAX_PATH_LEN
Trivial for players to trigger. Broken in commit 0b0612ea
, v4.3.16.
Spotted by the Clang Static Analyzer.
This commit is contained in:
parent
9b62b35424
commit
ad80846283
1 changed files with 1 additions and 1 deletions
|
@ -173,7 +173,7 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown,
|
||||||
if (p + strlen(bp) + 1 >= buf + MAX_PATH_LEN) {
|
if (p + strlen(bp) + 1 >= buf + MAX_PATH_LEN) {
|
||||||
pr("Path length may not exceed %d.\n", MAX_PATH_LEN);
|
pr("Path length may not exceed %d.\n", MAX_PATH_LEN);
|
||||||
pr("Aborting...\n");
|
pr("Aborting...\n");
|
||||||
bp = NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(p, bp);
|
strcpy(p, bp);
|
||||||
if (*bp)
|
if (*bp)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue