From 6e0a3f03e7ae5d8155861f64cc4d10df56d9a199 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 11 Mar 2026 14:04:57 +0100 Subject: DisplayTargetRank: check the return value of GetRankFileName() --- FICS/ratings.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'FICS/ratings.c') diff --git a/FICS/ratings.c b/FICS/ratings.c index 446a88d..05cd0b4 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -1905,29 +1905,25 @@ DisplayTargetRank(int p, char *target, int show, int showComp) int wildRank = -1, wildCount; if (CheckFlag(show, SHOW_BLITZ)) { - GetRankFileName(Path, sizeof Path, TYPE_BLITZ); - - if ((fb = fopen(Path, "r")) != NULL) + if (GetRankFileName(Path, sizeof Path, TYPE_BLITZ) >= 0 && + (fb = fopen(Path, "r")) != NULL) blitzRank = GetRank(fb, target, showComp); if (blitzRank < 0) ClearFlag(show, SHOW_BLITZ); } if (CheckFlag(show, SHOW_STANDARD)) { - GetRankFileName(Path, sizeof Path, TYPE_STAND); - if ((fs = fopen(Path, "r")) != NULL) + if (GetRankFileName(Path, sizeof Path, TYPE_STAND) >= 0 && + (fs = fopen(Path, "r")) != NULL) stdRank = GetRank(fs, target, showComp); if (stdRank < 0) ClearFlag(show, SHOW_STANDARD); } if (CheckFlag(show, SHOW_WILD)) { - GetRankFileName(Path, sizeof Path, TYPE_WILD); - - if (CheckFlag(show, SHOW_WILD)) - fw = fopen(Path, "r"); - if (fw != NULL) + if (GetRankFileName(Path, sizeof Path, TYPE_WILD) >= 0 && + (fw = fopen(Path, "r")) != NULL) wildRank = GetRank(fw, target, showComp); if (wildRank < 0) ClearFlag(show, SHOW_WILD); -- cgit v1.2.3