1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Fix out of range enum casts in deSerialize functions (#14090)

This commit is contained in:
cx384 2024-01-17 20:05:46 +01:00 committed by GitHub
parent 0383c44f0d
commit 2ea8d9ca11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 138 additions and 77 deletions

View file

@ -41,16 +41,23 @@ void TileAnimationParams::serialize(std::ostream &os, u16 protocol_ver) const
void TileAnimationParams::deSerialize(std::istream &is, u16 protocol_ver)
{
type = (TileAnimationType) readU8(is);
if (type == TAT_VERTICAL_FRAMES) {
vertical_frames.aspect_w = readU16(is);
vertical_frames.aspect_h = readU16(is);
vertical_frames.length = readF32(is);
} else if (type == TAT_SHEET_2D) {
sheet_2d.frames_w = readU8(is);
sheet_2d.frames_h = readU8(is);
sheet_2d.frame_length = readF32(is);
type = static_cast<TileAnimationType>(readU8(is));
switch(type) {
case TAT_NONE:
break;
case TAT_VERTICAL_FRAMES:
vertical_frames.aspect_w = readU16(is);
vertical_frames.aspect_h = readU16(is);
vertical_frames.length = readF32(is);
break;
case TAT_SHEET_2D:
sheet_2d.frames_w = readU8(is);
sheet_2d.frames_h = readU8(is);
sheet_2d.frame_length = readF32(is);
break;
default:
type = TAT_NONE;
break;
}
}