summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorGuilherme G. Menaldo <guilherme.menaldo@outlook.com>2018-03-01 02:12:57 -0300
committerGuilherme G. Menaldo <guilherme.menaldo@outlook.com>2018-03-08 23:14:22 -0300
commitc071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24 (patch)
tree6f19b0e13e7046599f0b54dd23715020d21119ce /src/map/clif.c
parent5b4f79ade2152da83e3c5df610efd54714acaa1f (diff)
downloadhercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.gz
hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.bz2
hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.tar.xz
hercules-c071cb6e4ab5eaac34e5cc2d54d8d0a441e8ea24.zip
Fixed a nullpo error when user tried to do an action in an unloaded mail in rodex
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 6b444553f..4d883eacb 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -19752,7 +19752,7 @@ void clif_rodex_send_maillist(int fd, struct map_session_data *sd, int8 open_typ
#endif
}
-void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
+void clif_rodex_send_mails_all(int fd, struct map_session_data *sd, int64 mail_id)
{
#if PACKETVER >= 20170419
struct PACKET_ZC_MAIL_LIST *packet;
@@ -19760,18 +19760,24 @@ void clif_rodex_send_mails_all(int fd, struct map_session_data *sd)
int16 size = sizeof(*packet);
int packetMailCount = 0;
int mailListCount = 0;
- int mailsSize = VECTOR_LENGTH(sd->rodex.messages);
- int i;
+ int mailsSize, i;
+ int j = -1;
nullpo_retv(sd);
+ mailsSize = VECTOR_LENGTH(sd->rodex.messages);
+
+ if (mail_id > 0)
+ ARR_FIND(0, VECTOR_LENGTH(sd->rodex.messages), j, (VECTOR_INDEX(sd->rodex.messages, j)).id == mail_id);
+
WFIFOHEAD(fd, sizeof(*packet) + (sizeof(*inner) + RODEX_TITLE_LENGTH) * RODEX_MAIL_PER_PAGE);
packet = WFIFOP(fd, 0);
packet->PacketType = rodexmailList;
inner = WFIFOP(fd, size);
i = mailsSize - 1;
- while (i >= 0) {
+ mailsSize -= (j + 1);
+ while (i > j) {
struct rodex_message *msg = &VECTOR_INDEX(sd->rodex.messages, i);
--i;