From dec87bececa197d1b7639000a5e8edc779a30c9a Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Wed, 4 Dec 2024 02:39:46 +0100 Subject: Fixed the usage of a possibly uninitialized variable, found by PVS-Studio --- FICS/lists.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/FICS/lists.c b/FICS/lists.c index c76e645..5f3a42a 100644 --- a/FICS/lists.c +++ b/FICS/lists.c @@ -278,7 +278,7 @@ list_addsub(int p, char *list, char *who, int addsub) List *gl; char *listname, *member; char *yourthe, *addrem; - int p1, connected, loadme, personal, ch; + int p1 = -1, connected, loadme, personal, ch; if ((gl = list_findpartial(p, list, addsub)) == NULL) return COM_OK; @@ -374,6 +374,10 @@ list_addsub(int p, char *list, char *who, int addsub) addrem, listname); break; case L_COMPUTER: + if (p1 < 0) { + warnx("%s: negative player number", __func__); + break; + } if (parray[p1].b_stats.rating > 0) { UpdateRank(TYPE_BLITZ, member, &parray[p1].b_stats, member); @@ -388,6 +392,10 @@ list_addsub(int p, char *list, char *who, int addsub) } break; case L_ADMIN: + if (p1 < 0) { + warnx("%s: negative player number", __func__); + break; + } if (addsub == 1) { // adding to list parray[p1].adminLevel = 10; pprintf(p, "%s has been given an admin level " -- cgit v1.2.3