diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-25 21:41:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-31 23:06:29 +0300 |
commit | f0d5be2db32afc7b4382276ffa3c60a1354bea8e (patch) | |
tree | 919fc1db442339a32a88bde0fa6f68e320e64dce /src/map | |
parent | a71a056abb8931aa4a11d0cde296fe9de68ee6df (diff) | |
download | hercules-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')
-rw-r--r-- | src/map/HPMmap.c | 8 | ||||
-rw-r--r-- | src/map/atcommand.c | 12 | ||||
-rw-r--r-- | src/map/battle.c | 2 | ||||
-rw-r--r-- | src/map/battleground.c | 11 | ||||
-rw-r--r-- | src/map/clif.c | 1 | ||||
-rw-r--r-- | src/map/guild.c | 28 | ||||
-rw-r--r-- | src/map/instance.c | 38 | ||||
-rw-r--r-- | src/map/itemdb.c | 80 | ||||
-rw-r--r-- | src/map/map.c | 64 | ||||
-rw-r--r-- | src/map/mob.c | 14 | ||||
-rw-r--r-- | src/map/npc.c | 18 | ||||
-rw-r--r-- | src/map/party.c | 31 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 6 | ||||
-rw-r--r-- | src/map/skill.c | 3 | ||||
-rw-r--r-- | src/map/status.c | 16 | ||||
-rw-r--r-- | src/map/unit.c | 28 |
17 files changed, 203 insertions, 159 deletions
diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index f1cdec538..cb4e79108 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -181,11 +181,13 @@ void HPM_map_do_final(void) { * why is pcg->HPM being cleared here? because PCG's do_final is not final, * is used on reload, and would thus cause plugin-provided permissions to go away **/ - for( i = 0; i < pcg->HPMpermissions_count; i++ ) { - aFree(pcg->HPMpermissions[i].name); - } if( pcg->HPMpermissions ) + { + for( i = 0; i < pcg->HPMpermissions_count; i++ ) { + aFree(pcg->HPMpermissions[i].name); + } aFree(pcg->HPMpermissions); + } HPM->datacheck_final(); } diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 330fe6284..74a9531e5 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1315,9 +1315,7 @@ ACMD(baselevelup) { int level=0, i=0, status_point=0; - level = atoi(message); - - if (!message || !*message || !level) { + if (!message || !*message || !(level = atoi(message))) { clif->message(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>). return false; } @@ -1376,9 +1374,7 @@ ACMD(joblevelup) { int level=0; - level = atoi(message); - - if (!message || !*message || !level) { + if (!message || !*message || !(level = atoi(message))) { clif->message(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>). return false; } @@ -8570,10 +8566,12 @@ ACMD(cart) { sd->status.skill[idx].flag = (x)?1:0; \ } while(0) - int val = atoi(message); + int val; bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true; unsigned int index = skill->get_index(MC_PUSHCART); + if (message) + val = atoi(message); if( !message || !*message || val < 0 || val > MAX_CARTS ) { sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>). clif->message(fd, atcmd_output); diff --git a/src/map/battle.c b/src/map/battle.c index ddad2c705..263670ea3 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2594,6 +2594,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam nullpo_ret(bl); + // need check src for null pointer? + if( !damage ) return 0; if( battle_config.ksprotection && mob->ksprotected(src, bl) ) diff --git a/src/map/battleground.c b/src/map/battleground.c index 190f7886d..94a6f0626 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -860,13 +860,14 @@ void do_final_battleground(void) { db_destroy(bg->team_db); - for( i = 0; i < bg->arenas; i++ ) { - if( bg->arena[i] ) - aFree(bg->arena[i]); - } - if( bg->arena ) + { + for( i = 0; i < bg->arenas; i++ ) { + if( bg->arena[i] ) + aFree(bg->arena[i]); + } aFree(bg->arena); + } } void battleground_defaults(void) { bg = &bg_s; diff --git a/src/map/clif.c b/src/map/clif.c index a1eb6662f..9309ad7b3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4749,6 +4749,7 @@ int clif_outsight(struct block_list *bl,va_list ap) TBL_PC *sd, *tsd; tbl=va_arg(ap,struct block_list*); if(bl == tbl) return 0; + // bl can be null pointer? and after if BL_PC, sd will be null pointer too sd = BL_CAST(BL_PC, bl); tsd = BL_CAST(BL_PC, tbl); diff --git a/src/map/guild.c b/src/map/guild.c index d46da60a3..3d5a0e09e 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1785,14 +1785,16 @@ int guild_broken(int guild_id,int flag) if( g->instance ) aFree(g->instance); - for( i = 0; i < g->hdatac; i++ ) { - if( g->hdata[i]->flag.free ) { - aFree(g->hdata[i]->data); - } - aFree(g->hdata[i]); - } if( g->hdata ) + { + for( i = 0; i < g->hdatac; i++ ) { + if( g->hdata[i]->flag.free ) { + aFree(g->hdata[i]->data); + } + aFree(g->hdata[i]); + } aFree(g->hdata); + } idb_remove(guild->db,guild_id); return 0; @@ -2279,14 +2281,16 @@ void do_final_guild(void) { aFree(g->instance); g->instance = NULL; } - for( i = 0; i < g->hdatac; i++ ) { - if( g->hdata[i]->flag.free ) { - aFree(g->hdata[i]->data); - } - aFree(g->hdata[i]); - } if( g->hdata ) + { + for( i = 0; i < g->hdatac; i++ ) { + if( g->hdata[i]->flag.free ) { + aFree(g->hdata[i]->data); + } + aFree(g->hdata[i]); + } aFree(g->hdata); + } } dbi_destroy(iter); 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; 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; diff --git a/src/map/map.c b/src/map/map.c index 25d7ce692..2820ac1fe 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3158,10 +3158,10 @@ void map_clean(int i) { } if( map->list[i].unit_count ) { - for(v = 0; v < map->list[i].unit_count; v++) { - aFree(map->list[i].units[v]); - } if( map->list[i].units ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); + } aFree(map->list[i].units); map->list[i].units = NULL; } @@ -3169,10 +3169,10 @@ void map_clean(int i) { } if( map->list[i].skill_count ) { - for(v = 0; v < map->list[i].skill_count; v++) { - aFree(map->list[i].skills[v]); - } if( map->list[i].skills ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); + } aFree(map->list[i].skills); map->list[i].skills = NULL; } @@ -3180,10 +3180,10 @@ void map_clean(int i) { } if( map->list[i].zone_mf_count ) { - for(v = 0; v < map->list[i].zone_mf_count; v++) { - aFree(map->list[i].zone_mf[v]); - } if( map->list[i].zone_mf ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); + } aFree(map->list[i].zone_mf); map->list[i].zone_mf = NULL; } @@ -3211,10 +3211,10 @@ void do_final_maps(void) { } if( map->list[i].unit_count ) { - for(v = 0; v < map->list[i].unit_count; v++) { - aFree(map->list[i].units[v]); - } if( map->list[i].units ) { + for(v = 0; v < map->list[i].unit_count; v++) { + aFree(map->list[i].units[v]); + } aFree(map->list[i].units); map->list[i].units = NULL; } @@ -3222,10 +3222,10 @@ void do_final_maps(void) { } if( map->list[i].skill_count ) { - for(v = 0; v < map->list[i].skill_count; v++) { - aFree(map->list[i].skills[v]); - } if( map->list[i].skills ) { + for(v = 0; v < map->list[i].skill_count; v++) { + aFree(map->list[i].skills[v]); + } aFree(map->list[i].skills); map->list[i].skills = NULL; } @@ -3233,10 +3233,10 @@ void do_final_maps(void) { } if( map->list[i].zone_mf_count ) { - for(v = 0; v < map->list[i].zone_mf_count; v++) { - aFree(map->list[i].zone_mf[v]); - } if( map->list[i].zone_mf ) { + for(v = 0; v < map->list[i].zone_mf_count; v++) { + aFree(map->list[i].zone_mf[v]); + } aFree(map->list[i].zone_mf); map->list[i].zone_mf = NULL; } @@ -3255,14 +3255,16 @@ void do_final_maps(void) { if( map->list[i].qi_data ) aFree(map->list[i].qi_data); - for( v = 0; v < map->list[i].hdatac; v++ ) { - if( map->list[i].hdata[v]->flag.free ) { - aFree(map->list[i].hdata[v]->data); - } - aFree(map->list[i].hdata[v]); - } if( map->list[i].hdata ) + { + for( v = 0; v < map->list[i].hdatac; v++ ) { + if( map->list[i].hdata[v]->flag.free ) { + aFree(map->list[i].hdata[v]->data); + } + aFree(map->list[i].hdata[v]); + } aFree(map->list[i].hdata); + } } map->zone_db_clear(); @@ -5927,13 +5929,15 @@ int do_init(int argc, char *argv[]) vending->init(minimal); if (scriptcheck) { - bool failed = load_extras_count > 0 ? false : true; - for (i = 0; i < load_extras_count; i++) { - if (npc->parsesrcfile(load_extras[i], false) != EXIT_SUCCESS) - failed = true; + if (load_extras) { + bool failed = load_extras_count > 0 ? false : true; + for (i = 0; i < load_extras_count; i++) { + if (npc->parsesrcfile(load_extras[i], false) != EXIT_SUCCESS) + failed = true; + } + if (failed) + exit(EXIT_FAILURE); } - if (failed) - exit(EXIT_FAILURE); exit(EXIT_SUCCESS); } if (load_extras) { diff --git a/src/map/mob.c b/src/map/mob.c index 96ee83d3b..ce5854928 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -4716,14 +4716,16 @@ void mob_destroy_mob_db(int index) { struct mob_db *data = mob->db_data[index]; int v; - for (v = 0; v < data->hdatac; v++ ) { - if (data->hdata[v]->flag.free ) { - aFree(data->hdata[v]->data); - } - aFree(data->hdata[v]); - } if (data->hdata) + { + for (v = 0; v < data->hdatac; v++ ) { + if (data->hdata[v]->flag.free ) { + aFree(data->hdata[v]->data); + } + aFree(data->hdata[v]); + } aFree(data->hdata); + } aFree(data); mob->db_data[index] = NULL; } 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; diff --git a/src/map/party.c b/src/map/party.c index 668251b5d..1df916630 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -103,15 +103,17 @@ int party_db_final(DBKey key, DBData *data, va_list ap) { if( p->instance ) aFree(p->instance); - - for( j = 0; j < p->hdatac; j++ ) { - if( p->hdata[j]->flag.free ) { - aFree(p->hdata[j]->data); + + if (p->hdata) + { + for (j = 0; j < p->hdatac; j++) { + if (p->hdata[j]->flag.free) { + aFree(p->hdata[j]->data); + } + aFree(p->hdata[j]); } - aFree(p->hdata[j]); - } - if( p->hdata ) aFree(p->hdata); + } } return 0; @@ -609,15 +611,16 @@ int party_broken(int party_id) if( p->instance ) aFree(p->instance); - for( j = 0; j < p->hdatac; j++ ) { - if( p->hdata[j]->flag.free ) { - aFree(p->hdata[j]->data); - } - aFree(p->hdata[j]); - } if( p->hdata ) + { + for( j = 0; j < p->hdatac; j++ ) { + if( p->hdata[j]->flag.free ) { + aFree(p->hdata[j]->data); + } + aFree(p->hdata[j]); + } aFree(p->hdata); - + } idb_remove(party->db,party_id); return 0; } diff --git a/src/map/pc.c b/src/map/pc.c index 356b57e5b..9468a34f6 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6915,6 +6915,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { int i=0,j=0; int64 tick = timer->gettick(); + nullpo_retr(0, sd); + for(j = 0; j < 5; j++) { if (sd->devotion[j]){ struct map_session_data *devsd = map->id2sd(sd->devotion[j]); diff --git a/src/map/script.c b/src/map/script.c index 031dfc21b..7634b6c68 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -767,6 +767,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) char null_arg = '\0'; int func; + // is need add check for arg null pointer below? func = script->add_word(p); if( script->str_data[func].type == C_FUNC ) { // buildin function @@ -2593,10 +2594,11 @@ void* get_val2(struct script_state* st, int64 uid, struct reg_db *ref) { **/ void script_array_ensure_zero(struct script_state *st, struct map_session_data *sd, int64 uid, struct reg_db *ref) { const char *name = script->get_str(script_getvarid(uid)); + // is here st can be null pointer and st->rid is wrong? struct reg_db *src = script->array_src(st, sd ? sd : st->rid ? map->id2sd(st->rid) : NULL, name, ref); struct script_array *sa = NULL; bool insert = false; - + if( sd && !st ) /* when sd comes, st isn't available */ insert = true; else { @@ -4385,7 +4387,7 @@ void do_final_script(void) { aFree(script->hq[i].item); } } - if( script->hqis ) { + if (script->hqis && script->hqi) { for( i = 0; i < script->hqis; i++ ) { if( script->hqi[i].item != NULL ) aFree(script->hqi[i].item); diff --git a/src/map/skill.c b/src/map/skill.c index 5eb319c02..a89f61a49 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1653,7 +1653,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1 sd->state.autocast = 0; } - if( sd && sd->autobonus3[0].rate ) { + if (sd->autobonus3[0].rate) { for( i = 0; i < ARRAYLENGTH(sd->autobonus3); i++ ) { if( rnd()%1000 >= sd->autobonus3[i].rate ) continue; @@ -16255,6 +16255,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { } } + // useless check for !group ? //Don't continue if unit or even group is expired and has been deleted. if( !group || !su->alive ) return 0; diff --git a/src/map/status.c b/src/map/status.c index 9cd01f7b3..89e263412 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -3093,11 +3093,13 @@ int status_calc_elemental_(struct elemental_data *ed, enum e_status_calc_opt opt } int status_calc_npc_(struct npc_data *nd, enum e_status_calc_opt opt) { - struct status_data *nstatus = &nd->status; + struct status_data *nstatus; if (!nd) return 0; + nstatus = &nd->status; + if ( opt&SCO_FIRST ) { nstatus->hp = 1; nstatus->sp = 1; @@ -3646,7 +3648,8 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { if(flag&SCB_MAXHP) { if( bl->type&BL_PC ) { st->max_hp = status->base_pc_maxhp(sd,st); - st->max_hp += bst->max_hp - sd->status.max_hp; + if (sd) + st->max_hp += bst->max_hp - sd->status.max_hp; st->max_hp = status->calc_maxhp(bl, sc, st->max_hp); @@ -3666,7 +3669,8 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { if(flag&SCB_MAXSP) { if( bl->type&BL_PC ) { st->max_sp = status->base_pc_maxsp(sd,st); - st->max_sp += bst->max_sp - sd->status.max_sp; + if (sd) + st->max_sp += bst->max_sp - sd->status.max_sp; st->max_sp = status->calc_maxsp(&sd->bl, &sd->sc, st->max_sp); @@ -9541,10 +9545,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t if(opt_flag) { clif->changeoption(bl); if( sd && opt_flag&0x4 ) { - clif->changelook(bl,LOOK_BASE,vd->class_); + if (vd) + clif->changelook(bl,LOOK_BASE,vd->class_); clif->changelook(bl,LOOK_WEAPON,0); clif->changelook(bl,LOOK_SHIELD,0); - clif->changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color); + if (vd) + clif->changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color); } } if (calc_flag&SCB_DYE) { diff --git a/src/map/unit.c b/src/map/unit.c index a5bd282a9..deb061f78 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2657,14 +2657,16 @@ int unit_free(struct block_list *bl, clr_type clrtype) { sd->num_quests = sd->avail_quests = 0; } - for( k = 0; k < sd->hdatac; k++ ) { - if( sd->hdata[k]->flag.free ) { - aFree(sd->hdata[k]->data); - } - aFree(sd->hdata[k]); - } if( sd->hdata ) + { + for( k = 0; k < sd->hdatac; k++ ) { + if( sd->hdata[k]->flag.free ) { + aFree(sd->hdata[k]->data); + } + aFree(sd->hdata[k]); + } aFree(sd->hdata); + } break; } case BL_PET: @@ -2776,14 +2778,16 @@ int unit_free(struct block_list *bl, clr_type clrtype) { if( md->tomb_nid ) mob->mvptomb_destroy(md); - for (k = 0; k < md->hdatac; k++) { - if( md->hdata[k]->flag.free ) { - aFree(md->hdata[k]->data); - } - aFree(md->hdata[k]); - } if (md->hdata) + { + for (k = 0; k < md->hdatac; k++) { + if( md->hdata[k]->flag.free ) { + aFree(md->hdata[k]->data); + } + aFree(md->hdata[k]); + } aFree(md->hdata); + } break; } case BL_HOM: |