aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-11-18 19:27:36 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2025-11-18 19:27:36 +0100
commit73c9f4bdbc784d2df07d3abe125c8166210f41fa (patch)
tree83568186460f1313070e5a7077661d89530992fa
parent3aa1e8e41036542e6d88898603cd3244f19b68e8 (diff)
Fixed null pointer dereference in UpdateRank() -- found by PVS-Studio
-rw-r--r--FICS/ratings.c12
1 files changed, 10 insertions, 2 deletions
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;
}