Fixed potential crash in RODex (#7833)

This commit is contained in:
Jittapan Pluemsumran 2023-07-04 11:39:54 +09:00 committed by GitHub
parent f20f8b01be
commit 458a9d8950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,6 +190,9 @@ enum mail_attach_result mail_setitem(map_session_data *sd, short idx, uint32 amo
for( j = 0; j < MAIL_MAX_ITEM; j++ ){
if (sd->mail.item[j].nameid == 0)
continue;
if (sd->inventory_data[sd->mail.item[j].index] == nullptr) {
return MAIL_ATTACH_ERROR;
}
total += sd->mail.item[j].amount * ( sd->inventory_data[sd->mail.item[j].index]->weight / 10 );
}
@ -215,6 +218,9 @@ enum mail_attach_result mail_setitem(map_session_data *sd, short idx, uint32 amo
if( battle_config.mail_attachment_weight ){
// Only need to sum up all entries until the new entry
for( j = 0; j < i; j++ ){
if (sd->inventory_data[sd->mail.item[j].index] == nullptr) {
return MAIL_ATTACH_ERROR;
}
total += sd->mail.item[j].amount * ( sd->inventory_data[sd->mail.item[j].index]->weight / 10 );
}