From 73c9f4bdbc784d2df07d3abe125c8166210f41fa Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Tue, 18 Nov 2025 19:27:36 +0100 Subject: Fixed null pointer dereference in UpdateRank() -- found by PVS-Studio --- FICS/ratings.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'FICS/ratings.c') diff --git a/FICS/ratings.c b/FICS/ratings.c index 8113c6d..a207627 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -1530,8 +1530,16 @@ UpdateRank(int type, char *addName, statistics *sNew, char *delName) CompareStats(addName, sNew, login, &sCur) > 0) { int computer = in_list(-1, L_COMPUTER, addName); - fprintf(fptemp, "%s %d %d %d\n", addName, sNew->rating, - sNew->num, computer); + if (sNew) { + fprintf(fptemp, "%s %d %d %d\n", addName, + sNew->rating, sNew->num, computer); + } else { + warnx("%s: 'sNew' null: addName = %s", __func__, + addName); + fprintf(fptemp, "%s %d %d %d\n", addName, + 0, 0, computer); + } + addName = NULL; } -- cgit v1.2.3