From 2c9c1e2eb8e74a6f8d9765993365648555ddf9b0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 30 Mar 2016 21:10:18 +0300 Subject: Add missing checks. --- src/emap/pc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/emap/pc.c') diff --git a/src/emap/pc.c b/src/emap/pc.c index 1c7c74e..c7203d0 100644 --- a/src/emap/pc.c +++ b/src/emap/pc.c @@ -94,7 +94,7 @@ void epc_equipitem_pos(TBL_PC *sd, struct item_data *id, int *nPtr, int *posPtr) hookStop(); - if (!id) + if (!id || !sd) return; if (pos & (EQP_HAND_R|EQP_SHADOW_WEAPON)) @@ -445,6 +445,8 @@ bool epc_can_insert_card_into_post(bool retVal, struct map_session_data* sd, int f; if (retVal) { + if (!sd) + return retVal; struct ItemdExt *data = itemd_get(sd->inventory_data[*idx_equip]); if (!data || !data->allowedCards[0].id) // allow cards if AllowedCards list is empty return retVal; @@ -484,7 +486,7 @@ static int tempAmount = 0; int epc_dropitem_pre(struct map_session_data *sd, int *nPtr, int *amountPtr) { const int n = *nPtr; - if (n < 0 || n >= MAX_INVENTORY) + if (!sd || n < 0 || n >= MAX_INVENTORY) { tempN = 0; tempId = 0; @@ -542,8 +544,11 @@ int epc_takeitem_post(int retVal, struct map_session_data *sd, struct flooritem_ int epc_insert_card_pre(struct map_session_data* sd, int *idx_card, int *idx_equip) { - if (!sd || *idx_equip < 0 || *idx_equip >= MAX_INVENTORY || - *idx_card < 0 || *idx_card >= MAX_INVENTORY) + if (!sd || + *idx_equip < 0 || + *idx_equip >= MAX_INVENTORY || + *idx_card < 0 || + *idx_card >= MAX_INVENTORY) { tempN = 0; tempId = 0; -- cgit v1.2.3-60-g2f50