Skip to content

Commit a90f2ef

Browse files
ClobberXDSmallJoker
authored andcommittedMay 21, 2019
Check for out-of-bounds breath when setting breath_max (#8493)
1 parent 920bd3b commit a90f2ef

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎src/script/lua_api/l_object.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -750,17 +750,26 @@ int ObjectRef::l_set_properties(lua_State *L)
750750
NO_MAP_LOCK_REQUIRED;
751751
ObjectRef *ref = checkobject(L, 1);
752752
ServerActiveObject *co = getobject(ref);
753-
if (co == NULL) return 0;
753+
if (!co)
754+
return 0;
755+
754756
ObjectProperties *prop = co->accessObjectProperties();
755757
if (!prop)
756758
return 0;
759+
757760
read_object_properties(L, 2, prop, getServer(L)->idef());
761+
758762
if (prop->hp_max < co->getHP()) {
759763
PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP);
760764
co->setHP(prop->hp_max, reason);
761765
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
762766
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co, reason);
763767
}
768+
769+
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER &&
770+
prop->breath_max < co->getBreath())
771+
co->setBreath(prop->breath_max);
772+
764773
co->notifyObjectPropertiesModified();
765774
return 0;
766775
}

0 commit comments

Comments
 (0)
Please sign in to comment.