diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2025-11-18 18:43:32 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2025-11-18 18:43:32 +0100 |
| commit | 52b1d966d59227e716044adc0463314ec3ed6c7c (patch) | |
| tree | c7f662e671ec33579791af97a617816b5939de1c /FICS | |
| parent | b372c97b3a3dadcc2c5ef8aba5a453b6af1e8010 (diff) | |
Fixed possible array underrun -- found by PVS-Studio
Diffstat (limited to 'FICS')
| -rw-r--r-- | FICS/movecheck.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c index 5f607de..bb50369 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -31,6 +31,8 @@ #include "stdinclude.h" +#include <err.h> + #include "algcheck.h" #include "board.h" #include "common.h" @@ -719,6 +721,15 @@ legal_move(game_state_t *gs, int legal; int move_piece; + if (gs == NULL) { + warnx("%s: hoser! null game state", __func__); + return 0; + } else if ((fFile < 0 && fFile != ALG_DROP) || + fFile >= (int)ARRAY_SIZE(gs->board)) { + warnx("%s: 'fFile' (%d) out of range", __func__, fFile); + return 0; + } + if (fFile == ALG_DROP) { move_piece = fRank; |
