summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 8b5bbc83e..2da99c0bd 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2308,16 +2308,18 @@ int npc_unload(struct npc_data* nd, bool single) {
aFree(nd->ud);
nd->ud = NULL;
}
-
- for( i = 0; i < nd->hdatac; i++ ) {
- if( nd->hdata[i]->flag.free ) {
- aFree(nd->hdata[i]->data);
- }
- aFree(nd->hdata[i]);
- }
+
if( nd->hdata )
+ {
+ for( i = 0; i < nd->hdatac; i++ ) {
+ if( nd->hdata[i]->flag.free ) {
+ aFree(nd->hdata[i]->data);
+ }
+ aFree(nd->hdata[i]);
+ }
aFree(nd->hdata);
-
+ }
+
aFree(nd);
return 0;