From c0aedc4c41ebc4959344a283ac7ea4a2296fb204 Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 11 Oct 2008 06:57:14 +0000 Subject: Added safeguards to Redemptio's exp penalty code to prevent arithmetic overflow in case its requirement checks are somehow bypassed (see topic:152196). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13277 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/pc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index ca395d955..7774680f7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5172,10 +5172,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) if(base_penalty) { if (battle_config.pk_mode && src && src->type==BL_PC) base_penalty*=2; - if(sd->status.base_exp < base_penalty) - sd->status.base_exp = 0; - else - sd->status.base_exp -= base_penalty; + sd->status.base_exp -= min(sd->status.base_exp, base_penalty); clif_updatestatus(sd,SP_BASEEXP); } } @@ -5193,10 +5190,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) if(base_penalty) { if (battle_config.pk_mode && src && src->type==BL_PC) base_penalty*=2; - if(sd->status.job_exp < base_penalty) - sd->status.job_exp = 0; - else - sd->status.job_exp -= base_penalty; + sd->status.job_exp -= min(sd->status.job_exp, base_penalty); clif_updatestatus(sd,SP_JOBEXP); } } -- cgit v1.2.3-70-g09d2