From 072b831c2cf88f3161c0a0c2e4742d8f30f9701a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 21 Mar 2019 07:12:32 +0300 Subject: Fix possible null pointers --- src/map/clif.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/map/clif.c') 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); } -- cgit v1.2.3-60-g2f50