瀏覽代碼

* Changed val4 of SC_BLADESTOP from a block_list pointer to an id. (64bit portability issue and potential dangling pointer crash)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13471 54d463be-8e91-2dee-dedb-b68131a5f0ec
FlavioJS 16 年之前
父節點
當前提交
e3d5e89496
共有 6 個文件被更改,包括 16 次插入16 次删除
  1. 2 0
      Changelog-Trunk.txt
  2. 3 3
      src/map/battle.c
  3. 3 7
      src/map/clif.c
  4. 1 1
      src/map/clif.h
  5. 6 4
      src/map/status.c
  6. 1 1
      src/map/unit.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2009/01/22
+	* Changed val4 of SC_BLADESTOP from a block_list pointer to an id. [FlavioJS]
 2009/01/21
 	* Added a limit of 1MB of pending data in the write fifo for non-server sockets.
 	  Connections that go over the limit are closed.

+ 3 - 3
src/map/battle.c

@@ -2903,11 +2903,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 			int skilllv = tsc->data[SC_BLADESTOP_WAIT]->val1;
 			int duration = skill_get_time2(MO_BLADESTOP,skilllv);
 			status_change_end(target, SC_BLADESTOP_WAIT, -1);
-			if(sc_start4(src, SC_BLADESTOP, 100, sd?pc_checkskill(sd, MO_BLADESTOP):5, 0, 0, (int)target, duration))
+			if(sc_start4(src, SC_BLADESTOP, 100, sd?pc_checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration))
 		  	{	//Target locked.
 				clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
-				clif_bladestop(target,src,1);
-				sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0,(int)src, duration);
+				clif_bladestop(target, src->id, 1);
+				sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0, src->id, duration);
 				return ATK_NONE;
 			}
 		}

+ 3 - 7
src/map/clif.c

@@ -5957,22 +5957,18 @@ int clif_combo_delay(struct block_list *bl,int wait)
 /*==========================================
  *”’�nŽæ‚è
  *------------------------------------------*/
-int clif_bladestop(struct block_list *src,struct block_list *dst,
-	int _bool)
+void clif_bladestop(struct block_list *src, int dst_id, int active)
 {
 	unsigned char buf[32];
 
 	nullpo_retr(0, src);
-	nullpo_retr(0, dst);
 
 	WBUFW(buf,0)=0x1d1;
 	WBUFL(buf,2)=src->id;
-	WBUFL(buf,6)=dst->id;
-	WBUFL(buf,10)=_bool;
+	WBUFL(buf,6)=dst_id;
+	WBUFL(buf,10)=active;
 
 	clif_send(buf,packet_len(0x1d1),src,AREA);
-
-	return 0;
 }
 
 /*==========================================

+ 1 - 1
src/map/clif.h

@@ -236,7 +236,7 @@ int clif_autospell(struct map_session_data *sd,int skilllv);
 void clif_devotion(struct block_list *src, struct map_session_data *tsd);
 int clif_spiritball(struct map_session_data *sd);
 int clif_combo_delay(struct block_list *src,int wait);
-int clif_bladestop(struct block_list *src,struct block_list *dst,int bool_);
+void clif_bladestop(struct block_list* src, int dst_id, int active);
 void clif_changemapcell(int fd, int m, int x, int y, int type, enum send_target target);
 
 int clif_status_load(struct block_list *bl,int type, int flag);

+ 6 - 4
src/map/status.c

@@ -4549,9 +4549,10 @@ void status_set_viewdata(struct block_list *bl, int class_)
 		vd->cloth_color = 0;
 }
 
+/// Returns the status_change data of bl or NULL if it doesn't exist.
 struct status_change *status_get_sc(struct block_list *bl)
 {
-	nullpo_retr(NULL, bl);
+	if( bl )
 	switch (bl->type) {
 	case BL_PC:  return &((TBL_PC*)bl)->sc;
 	case BL_MOB: return &((TBL_MOB*)bl)->sc;
@@ -6582,15 +6583,16 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 		case SC_BLADESTOP:
 			if(sce->val4)
 			{
-				struct block_list *tbl = (struct block_list *)sce->val4;
+				int tid = sce->val4;
+				struct block_list *tbl = map_id2bl(tid);
 				struct status_change *tsc = status_get_sc(tbl);
 				sce->val4 = 0;
-				if(tsc && tsc->data[SC_BLADESTOP])
+				if(tbl && tsc && tsc->data[SC_BLADESTOP])
 				{
 					tsc->data[SC_BLADESTOP]->val4 = 0;
 					status_change_end(tbl,SC_BLADESTOP,-1);
 				}
-				clif_bladestop(bl,tbl,0);
+				clif_bladestop(bl, tid, 0);
 			}
 			break;
 		case SC_DANCING:

+ 1 - 1
src/map/unit.c

@@ -855,7 +855,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
 		{	//Check for skills that auto-select target
 		case MO_CHAINCOMBO:
 			if (sc && sc->data[SC_BLADESTOP]){
-				if ((target=(struct block_list *)sc->data[SC_BLADESTOP]->val4) == NULL)
+				if ((target=map_id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL)
 					return 0;
 			}
 			break;