From 087a56cf061e203bd4380708bad02efe792504be Mon Sep 17 00:00:00 2001 From: luk3yx Date: Wed, 7 Sep 2022 20:51:07 +1200 Subject: [PATCH] Don't crash with a negative length in particle definitions --- src/tileanimation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tileanimation.cpp b/src/tileanimation.cpp index a44d8be35..bba45205a 100644 --- a/src/tileanimation.cpp +++ b/src/tileanimation.cpp @@ -58,11 +58,12 @@ void TileAnimationParams::deSerialize(std::istream &is, u8 tiledef_version) if (type == TAT_VERTICAL_FRAMES || tiledef_version <= 2) { vertical_frames.aspect_w = readU16(is); vertical_frames.aspect_h = readU16(is); - vertical_frames.length = readF(is, protocol_version); + // Don't hang if a negative length is sent + vertical_frames.length = fabs(readF(is, protocol_version)); } else if (type == TAT_SHEET_2D) { sheet_2d.frames_w = readU8(is); sheet_2d.frames_h = readU8(is); - sheet_2d.frame_length = readF(is, protocol_version); + sheet_2d.frame_length = fabs(readF(is, protocol_version)); } }