diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-12-04 02:39:46 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-12-04 02:39:46 +0100 |
commit | dec87bececa197d1b7639000a5e8edc779a30c9a (patch) | |
tree | 8e946edfa203b7af7b4c4528a75480d48ace7529 /FICS | |
parent | c7e0bad343efb01501a1277c2b16bea9373adcd0 (diff) |
Fixed the usage of a possibly uninitialized variable, found by PVS-Studio
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/lists.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 " |