Преглед изворни кода

* Added temporary check to skill_delunitgroup to prevent crashes when 'group' is NULL and added some debug messages to track down the source of the crash (bugreport:3504).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14599 54d463be-8e91-2dee-dedb-b68131a5f0ec
ai4rei пре 14 година
родитељ
комит
ddbbf5e603
4 измењених фајлова са 18 додато и 3 уклоњено
  1. 1 0
      Changelog-Trunk.txt
  2. 6 2
      src/map/skill.c
  3. 2 1
      src/map/skill.h
  4. 9 0
      src/map/status.c

+ 1 - 0
Changelog-Trunk.txt

@@ -1,6 +1,7 @@
 Date	Added
 
 2010/12/17
+	* Added temporary check to skill_delunitgroup to prevent crashes when 'group' is NULL and added some debug messages to track down the source of the crash (bugreport:3504). [Ai4rei]
 	* Spellchecked script_commands.txt. [Ai4rei]
 	* Random script engine clean-ups that have accumulated over time. [Ai4rei]
 	- Resolved unnecessary script_getnum re-evaluation in a loop in script command 'npcshopdelitem' (since r7120).

+ 6 - 2
src/map/skill.c

@@ -10161,13 +10161,17 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count,
 /*==========================================
  *
  *------------------------------------------*/
-int skill_delunitgroup (struct skill_unit_group *group)
+int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int line, const char* func)
 {
 	struct block_list* src;
 	struct unit_data *ud;
 	int i,j;
 
-	nullpo_ret(group);
+	if( group == NULL )
+	{
+		ShowDebug("skill_delunitgroup: group is NULL (source=%s:%d, %s)! Please report this! (#3504)\n", file, line, func);
+		return 0;
+	}
 
 	src=map_id2bl(group->src_id);
 	ud = unit_bl2ud(src);

+ 2 - 1
src/map/skill.h

@@ -272,7 +272,8 @@ struct skill_unit_group *skill_unitsetting(struct block_list* src, short skillid
 struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int x, int y, int val1, int val2);
 int skill_delunit(struct skill_unit *unit);
 struct skill_unit_group *skill_initunitgroup(struct block_list* src, int count, short skillid, short skilllv, int unit_id, int limit, int interval);
-int skill_delunitgroup(struct skill_unit_group *group);
+int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int line, const char* func);
+#define skill_delunitgroup(group) skill_delunitgroup_(group,__FILE__,__LINE__,__func__)
 int skill_clear_unitgroup(struct block_list *src);
 int skill_clear_group(struct block_list *bl, int flag);
 

+ 9 - 0
src/map/status.c

@@ -6605,6 +6605,15 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 				if(sce->val2)
 				{// erase associated land skill
 					group = skill_id2group(sce->val2);
+
+					if( group == NULL )
+					{
+						ShowDebug("status_change_end: SC_DANCING is missing skill unit group (val1=%d, val2=%d, val3=%d, val4=%d, timer=%d, tid=%d, char_id=%d, map=%s, x=%d, y=%d). Please report this! (#3504)\n",
+							sce->val1, sce->val2, sce->val3, sce->val4, sce->timer, tid,
+							sd ? sd->status.char_id : 0,
+							mapindex_id2name(map_id2index(bl->m)), bl->x, bl->y);
+					}
+
 					sce->val2 = 0;
 					skill_delunitgroup(group);
 				}