summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-03-21 07:12:32 +0300
committerAndrei Karas <akaras@inbox.ru>2019-04-07 22:38:34 +0300
commit072b831c2cf88f3161c0a0c2e4742d8f30f9701a (patch)
tree281d88fe62b8fb0bf06001e030907896710a36c8 /src
parentfb6ae9943cdad5088d5bb0a1350bcef9ea36bcd1 (diff)
downloadhercules-072b831c2cf88f3161c0a0c2e4742d8f30f9701a.tar.gz
hercules-072b831c2cf88f3161c0a0c2e4742d8f30f9701a.tar.bz2
hercules-072b831c2cf88f3161c0a0c2e4742d8f30f9701a.tar.xz
hercules-072b831c2cf88f3161c0a0c2e4742d8f30f9701a.zip
Fix possible null pointers
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/clif.c20
2 files changed, 16 insertions, 6 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 798f50b13..c65b32132 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -6361,7 +6361,7 @@ static enum damage_lv battle_weapon_attack(struct block_list *src, struct block_
if (d_bl != NULL
&& ((d_bl->type == BL_MER && d_md->master != NULL && d_md->master->bl.id == target->id)
- || (d_bl->type == BL_PC && d_sd->devotion[sce->val2] == target->id)
+ || (d_sd != NULL && d_bl->type == BL_PC && d_sd->devotion[sce->val2] == target->id)
)
&& check_distance_bl(target, d_bl, sce->val3)
) {
diff --git a/src/map/clif.c b/src/map/clif.c
index 1e8a88df1..baf9abec7 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7739,17 +7739,27 @@ static void clif_devotion(struct block_list *src, struct map_session_data *tsd)
static void clif_spiritball(struct block_list *bl)
{
unsigned char buf[16];
- struct map_session_data *sd = BL_CAST(BL_PC,bl);
- struct homun_data *hd = BL_CAST(BL_HOM,bl);
nullpo_retv(bl);
WBUFW(buf, 0) = 0x1d0;
WBUFL(buf, 2) = bl->id;
WBUFW(buf, 6) = 0; //init to 0
- switch(bl->type){
- case BL_PC: WBUFW(buf, 6) = sd->spiritball; break;
- case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break;
+ switch (bl->type) {
+ case BL_PC:
+ {
+ struct map_session_data *sd = BL_CAST(BL_PC, bl);
+ nullpo_retv(sd);
+ WBUFW(buf, 6) = sd->spiritball;
+ break;
+ }
+ case BL_HOM:
+ {
+ struct homun_data *hd = BL_CAST(BL_HOM, bl);
+ nullpo_retv(hd);
+ WBUFW(buf, 6) = hd->homunculus.spiritball;
+ break;
+ }
}
clif->send(buf, packet_len(0x1d0), bl, AREA);
}