summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/chrif.c10
-rw-r--r--src/map/unit.c8
2 files changed, 10 insertions, 8 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index d6f0e5ef8..a09284830 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -126,8 +126,16 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) {
if ( session[fd] && session[fd]->session_data == node->sd )
session[fd]->session_data = NULL;
- if ( node->sd )
+ if ( node->sd ) {
+
+ if( node->sd->var_db )
+ node->sd->var_db->destroy(node->sd->var_db,script->reg_destroy);
+
+ if( node->sd->array_db )
+ node->sd->array_db->destroy(node->sd->array_db,script->array_free_db);
+
aFree(node->sd);
+ }
ers_free(chrif->auth_db_ers, node);
idb_remove(chrif->auth_db,account_id);
diff --git a/src/map/unit.c b/src/map/unit.c
index 2926661ad..96d2c7775 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2352,13 +2352,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) {
pc->delspiritball(sd,sd->spiritball,1);
for(i = 1; i < 5; i++)
pc->del_charm(sd, sd->charm[i], i);
-
- if( sd->var_db )
- sd->var_db->destroy(sd->var_db,script->reg_destroy);
-
- if( sd->array_db )
- sd->array_db->destroy(sd->array_db,script->array_free_db);
-
+
if( sd->st && sd->st->state != RUN ) {// free attached scripts that are waiting
script->free_state(sd->st);
sd->st = NULL;