瀏覽代碼

setnpcdisplay potential crash (#5721)

* Fixed a potential crash in npc_setdisplayname with floating npc

Thansk to @Lemongrass3110 !
Atemo 4 年之前
父節點
當前提交
8216a6d7f7
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/map/npc.cpp

+ 2 - 1
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);
 }