summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-27 01:24:34 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-27 01:24:34 +0000
commit3633262bf2d8db0dd3bd51370826120371aac4a0 (patch)
treec5ae0b332226049181786cbbd3d13515d2cd2491 /src/map/chrif.c
parentad74cd5605eb1d0d4e774216dd62b471a9721cbe (diff)
downloadhercules-3633262bf2d8db0dd3bd51370826120371aac4a0.tar.gz
hercules-3633262bf2d8db0dd3bd51370826120371aac4a0.tar.bz2
hercules-3633262bf2d8db0dd3bd51370826120371aac4a0.tar.xz
hercules-3633262bf2d8db0dd3bd51370826120371aac4a0.zip
- Changed status_point/skill_point to unsigned short. Adjusted the code as necessary to prevent overflows.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5762 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 06b1946cc..3a11222fb 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -861,7 +861,10 @@ int chrif_changedsex(int fd)
// remove specifical skills of Bard classes
for(i = 315; i <= 322; i++) {
if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) {
- sd->status.skill_point += sd->status.skill[i].lv;
+ if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv)
+ sd->status.skill_point = USHRT_MAX;
+ else
+ sd->status.skill_point += sd->status.skill[i].lv;
sd->status.skill[i].id = 0;
sd->status.skill[i].lv = 0;
}
@@ -869,7 +872,10 @@ int chrif_changedsex(int fd)
// remove specifical skills of Dancer classes
for(i = 323; i <= 330; i++) {
if (sd->status.skill[i].id > 0 && !sd->status.skill[i].flag) {
- sd->status.skill_point += sd->status.skill[i].lv;
+ if (sd->status.skill_point > USHRT_MAX - sd->status.skill[i].lv)
+ sd->status.skill_point = USHRT_MAX;
+ else
+ sd->status.skill_point += sd->status.skill[i].lv;
sd->status.skill[i].id = 0;
sd->status.skill[i].lv = 0;
}