diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-13 01:12:45 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-13 01:12:45 +0100 |
commit | a3308bde2eb692a111b8d4abc536a075763dcb1b (patch) | |
tree | 6c104c1ce2df950f766f572bcb60620840c8517d /FICS | |
parent | 800e4914e5b7d29baddf4eed3343a07df8415e59 (diff) |
Fixed use of possibly uninitialized variable in ShowMsgsBySender()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/playerdb.c | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c index 5c16d7c..316fe48 100644 --- a/FICS/playerdb.c +++ b/FICS/playerdb.c @@ -2095,42 +2095,47 @@ PUBLIC int player_show_messages(int p) } } -PUBLIC int ShowMsgsBySender(int p, param_list param) +PUBLIC int +ShowMsgsBySender(int p, param_list param) { - textlist *Head; - int p1, connected; - int nFrom, nTo; + int nFrom, nTo; + int p1, connected; + textlist *Head; - if (!FindPlayer(p, param[0].val.word, &p1, &connected)) - return -1; + if (!FindPlayer(p, param[0].val.word, &p1, &connected)) + return -1; - if (!parray[p1].registered) { - pprintf(p, "Player \"%s\" is unregistered and cannot send or receive messages.\n", - parray[p1].name); - return -1; /* no need to disconnect */ - } + if (!parray[p1].registered) { + pprintf(p, "Player \"%s\" is unregistered and cannot send or " + "receive messages.\n", parray[p1].name); + return -1; /* no need to disconnect */ + } - if (p != p1) { - nTo = LoadMsgs(p1, p+1, &Head); - if (nTo <= 0) { - pprintf(p, "%s has no messages from you.\n", parray[p1].name); - } else { - pprintf(p, "Messages to %s:\n", parray[p1].name); - ShowTextList (p, Head, 0); - ClearTextList(Head); - } - } - nFrom = LoadMsgs(p, p1+1, &Head); - if (nFrom <= 0) { - pprintf(p, "\nYou have no messages from %s.\n", parray[p1].name); - } else { - pprintf(p, "Messages from %s:\n", parray[p1].name); - ShowTextList (p, Head, 1); - ClearTextList(Head); - } - if (!connected) - player_remove(p1); - return (nFrom > 0 || nTo > 0); + nFrom = nTo = -1; + + if (p != p1) { + if ((nTo = LoadMsgs(p1, p + 1, &Head)) <= 0) { + pprintf(p, "%s has no messages from you.\n", + parray[p1].name); + } else { + pprintf(p, "Messages to %s:\n", parray[p1].name); + ShowTextList (p, Head, 0); + ClearTextList(Head); + } + } + + if ((nFrom = LoadMsgs(p, p1 + 1, &Head)) <= 0) { + pprintf(p, "\nYou have no messages from %s.\n", + parray[p1].name); + } else { + pprintf(p, "Messages from %s:\n", parray[p1].name); + ShowTextList (p, Head, 1); + ClearTextList(Head); + } + + if (!connected) + player_remove(p1); + return (nFrom > 0 || nTo > 0); } PUBLIC int ShowMsgRange (int p, int start, int end) |