From 52b1d966d59227e716044adc0463314ec3ed6c7c Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Tue, 18 Nov 2025 18:43:32 +0100 Subject: Fixed possible array underrun -- found by PVS-Studio --- FICS/movecheck.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 + #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; -- cgit v1.2.3