summaryrefslogtreecommitdiff
path: root/src/map/itemdb.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/itemdb.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/itemdb.c')
-rw-r--r--src/map/itemdb.c80
1 files changed, 44 insertions, 36 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 19cc02d21..cc9865496 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -2106,14 +2106,16 @@ void destroy_item_data(struct item_data* self, int free_self)
script->free_code(self->unequip_script);
if( self->combos )
aFree(self->combos);
- for (v = 0; v < self->hdatac; v++ ) {
- if (self->hdata[v]->flag.free ) {
- aFree(self->hdata[v]->data);
- }
- aFree(self->hdata[v]);
- }
if (self->hdata)
+ {
+ for (v = 0; v < self->hdatac; v++ ) {
+ if (self->hdata[v]->flag.free ) {
+ aFree(self->hdata[v]->data);
+ }
+ aFree(self->hdata[v]);
+ }
aFree(self->hdata);
+ }
#if defined(DEBUG)
// trash item
memset(self, 0xDD, sizeof(struct item_data));
@@ -2143,52 +2145,58 @@ void itemdb_clear(bool total) {
itemdb->destroy_item_data(itemdb->array[i], 1);
}
- for( i = 0; i < itemdb->group_count; i++ ) {
- if( itemdb->groups[i].nameid )
- aFree(itemdb->groups[i].nameid);
- }
-
if( itemdb->groups )
+ {
+ for( i = 0; i < itemdb->group_count; i++ ) {
+ if( itemdb->groups[i].nameid )
+ aFree(itemdb->groups[i].nameid);
+ }
aFree(itemdb->groups);
-
+ }
+
itemdb->groups = NULL;
itemdb->group_count = 0;
- for( i = 0; i < itemdb->chain_count; i++ ) {
- if( itemdb->chains[i].items )
- aFree(itemdb->chains[i].items);
- }
-
if( itemdb->chains )
+ {
+ for( i = 0; i < itemdb->chain_count; i++ ) {
+ if( itemdb->chains[i].items )
+ aFree(itemdb->chains[i].items);
+ }
aFree(itemdb->chains);
-
+ }
+
itemdb->chains = NULL;
itemdb->chain_count = 0;
- for( i = 0; i < itemdb->package_count; i++ ) {
- int c;
- for( c = 0; c < itemdb->packages[i].random_qty; c++ )
- aFree(itemdb->packages[i].random_groups[c].random_list);
- if( itemdb->packages[i].random_groups )
- aFree(itemdb->packages[i].random_groups);
- if( itemdb->packages[i].must_items )
- aFree(itemdb->packages[i].must_items);
- }
-
if( itemdb->packages )
+ {
+ for( i = 0; i < itemdb->package_count; i++ ) {
+ int c;
+ if (itemdb->packages[i].random_groups)
+ {
+ for( c = 0; c < itemdb->packages[i].random_qty; c++ )
+ aFree(itemdb->packages[i].random_groups[c].random_list);
+ aFree(itemdb->packages[i].random_groups);
+ }
+ if( itemdb->packages[i].must_items )
+ aFree(itemdb->packages[i].must_items);
+ }
aFree(itemdb->packages);
-
- itemdb->packages = NULL;
+ itemdb->packages = NULL;
+ }
itemdb->package_count = 0;
- for(i = 0; i < itemdb->combo_count; i++) {
- if( itemdb->combos[i]->script ) // Check if script was loaded
- script->free_code(itemdb->combos[i]->script);
- aFree(itemdb->combos[i]);
- }
if( itemdb->combos )
+ {
+ for(i = 0; i < itemdb->combo_count; i++) {
+ if( itemdb->combos[i]->script ) // Check if script was loaded
+ script->free_code(itemdb->combos[i]->script);
+ aFree(itemdb->combos[i]);
+ }
aFree(itemdb->combos);
-
+ }
+
itemdb->combos = NULL;
itemdb->combo_count = 0;