summaryrefslogtreecommitdiff
path: root/src/map/instance.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-25 21:41:07 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-31 23:06:29 +0300
commitf0d5be2db32afc7b4382276ffa3c60a1354bea8e (patch)
tree919fc1db442339a32a88bde0fa6f68e320e64dce /src/map/instance.c
parenta71a056abb8931aa4a11d0cde296fe9de68ee6df (diff)
downloadhercules-f0d5be2db32afc7b4382276ffa3c60a1354bea8e.tar.gz
hercules-f0d5be2db32afc7b4382276ffa3c60a1354bea8e.tar.bz2
hercules-f0d5be2db32afc7b4382276ffa3c60a1354bea8e.tar.xz
hercules-f0d5be2db32afc7b4382276ffa3c60a1354bea8e.zip
Add some missing null pointer checks after automatic checks.
Diffstat (limited to 'src/map/instance.c')
-rw-r--r--src/map/instance.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/map/instance.c b/src/map/instance.c
index 4140973b1..96bdcc053 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -430,28 +430,25 @@ void instance_del_map(int16 m) {
aFree(map->list[m].block);
aFree(map->list[m].block_mob);
- if( map->list[m].unit_count ) {
+ if (map->list[m].unit_count && map->list[m].units) {
for(i = 0; i < map->list[m].unit_count; i++) {
aFree(map->list[m].units[i]);
}
- if( map->list[m].units )
- aFree(map->list[m].units);
+ aFree(map->list[m].units);
}
- if( map->list[m].skill_count ) {
+ if (map->list[m].skill_count && map->list[m].skills) {
for(i = 0; i < map->list[m].skill_count; i++) {
aFree(map->list[m].skills[i]);
}
- if( map->list[m].skills )
- aFree(map->list[m].skills);
+ aFree(map->list[m].skills);
}
- if( map->list[m].zone_mf_count ) {
+ if (map->list[m].zone_mf_count && map->list[m].zone_mf) {
for(i = 0; i < map->list[m].zone_mf_count; i++) {
aFree(map->list[m].zone_mf[i]);
}
- if( map->list[m].zone_mf )
- aFree(map->list[m].zone_mf);
+ aFree(map->list[m].zone_mf);
}
if( map->list[m].qi_data )
@@ -548,9 +545,12 @@ void instance_destroy(int instance_id) {
iptr[j] = -1;
}
- while( instance->list[instance_id].num_map && last != instance->list[instance_id].map[0] ) { // Remove all maps from instance
- last = instance->list[instance_id].map[0];
- instance->del_map( instance->list[instance_id].map[0] );
+ if (instance->list[instance_id].map)
+ {
+ while( instance->list[instance_id].num_map && last != instance->list[instance_id].map[0] ) { // Remove all maps from instance
+ last = instance->list[instance_id].map[0];
+ instance->del_map( instance->list[instance_id].map[0] );
+ }
}
if( instance->list[instance_id].regs.vars )
@@ -572,14 +572,16 @@ void instance_destroy(int instance_id) {
instance->list[instance_id].state = INSTANCE_FREE;
instance->list[instance_id].num_map = 0;
- for( j = 0; j < instance->list[instance_id].hdatac; j++ ) {
- if( instance->list[instance_id].hdata[j]->flag.free ) {
- aFree(instance->list[instance_id].hdata[j]->data);
+ if (instance->list[instance_id].hdata)
+ {
+ for( j = 0; j < instance->list[instance_id].hdatac; j++ ) {
+ if( instance->list[instance_id].hdata[j]->flag.free ) {
+ aFree(instance->list[instance_id].hdata[j]->data);
+ }
+ aFree(instance->list[instance_id].hdata[j]);
}
- aFree(instance->list[instance_id].hdata[j]);
- }
- if( instance->list[instance_id].hdata )
aFree(instance->list[instance_id].hdata);
+ }
instance->list[instance_id].hdata = NULL;
instance->list[instance_id].hdatac = 0;