Added null pointer checks in map_delblock (#7930)

This commit is contained in:
Atemo
2024-01-26 15:02:51 +01:00
committed by GitHub
parent 04904c0947
commit e965e2794b

View File

@@ -349,7 +349,7 @@ int map_addblock(struct block_list* bl)
struct map_data *mapdata = map_getmapdata(m);
if (mapdata->cell == nullptr) // Player warped to a freed map. Stop them!
if (mapdata == nullptr || mapdata->cell == nullptr) // Player warped to a freed map. Stop them!
return 1;
if( x < 0 || x >= mapdata->xs || y < 0 || y >= mapdata->ys )
@@ -402,6 +402,8 @@ int map_delblock(struct block_list* bl)
struct map_data *mapdata = map_getmapdata(bl->m);
nullpo_ret(mapdata);
pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*mapdata->bxs;
if (bl->next)
@@ -409,8 +411,10 @@ int map_delblock(struct block_list* bl)
if (bl->prev == &bl_head) {
//Since the head of the list, update the block_list map of []
if (bl->type == BL_MOB) {
nullpo_ret(mapdata->block_mob);
mapdata->block_mob[pos] = bl->next;
} else {
nullpo_ret(mapdata->block);
mapdata->block[pos] = bl->next;
}
} else {
@@ -434,6 +438,8 @@ int map_delblock(struct block_list* bl)
*/
int map_moveblock(struct block_list *bl, int x1, int y1, t_tick tick)
{
nullpo_ret(bl);
int x0 = bl->x, y0 = bl->y;
status_change *sc = NULL;
int moveblock = ( x0/BLOCK_SIZE != x1/BLOCK_SIZE || y0/BLOCK_SIZE != y1/BLOCK_SIZE);