From 8216a6d7f78246a9da3f14aa312a6346adfd37f0 Mon Sep 17 00:00:00 2001 From: Atemo Date: Tue, 26 Jan 2021 01:02:16 +0100 Subject: [PATCH] setnpcdisplay potential crash (#5721) * Fixed a potential crash in npc_setdisplayname with floating npc Thansk to @Lemongrass3110 ! --- src/map/npc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map/npc.cpp b/src/map/npc.cpp index b1cd60b4f4..7cae71f130 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -3896,9 +3896,10 @@ bool npc_movenpc(struct npc_data* nd, int16 x, int16 y) void npc_setdisplayname(struct npc_data* nd, const char* newname) { nullpo_retv(nd); + struct map_data *mapdata = map_getmapdata(nd->bl.m); safestrncpy(nd->name, newname, sizeof(nd->name)); - if( map_getmapdata(nd->bl.m)->users ) + if( mapdata && mapdata->users ) clif_name_area(&nd->bl); }