summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/itemdb.c6
-rw-r--r--src/map/script.c2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index abe899412..76183d0ec 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2077,9 +2077,10 @@ int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
void itemdb_clear(bool total) {
int i;
// clear the previous itemdb data
- for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i )
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) {
if( itemdb->array[i] )
itemdb->destroy_item_data(itemdb->array[i], 1);
+ }
for( i = 0; i < itemdb->group_count; i++ ) {
if( itemdb->groups[i].nameid )
@@ -2120,7 +2121,8 @@ void itemdb_clear(bool total) {
itemdb->package_count = 0;
for(i = 0; i < itemdb->combo_count; i++) {
- script->free_code(itemdb->combos[i]->script);
+ if( itemdb->combos[i]->script ) // Check if script was loaded
+ script->free_code(itemdb->combos[i]->script);
aFree(itemdb->combos[i]);
}
if( itemdb->combos )
diff --git a/src/map/script.c b/src/map/script.c
index 8ac657f93..3e11a510e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3217,6 +3217,8 @@ void script_free_vars(struct DBMap* var_storage) {
void script_free_code(struct script_code* code)
{
+ nullpo_retv(code);
+
if( code->instances )
script->stop_instances(code);
else {