From 654e68fdbc56733a9a2e517125ee2ffee2e7b342 Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Fri, 31 May 2024 16:01:27 -0400 Subject: [PATCH] fixed #18, an animation start frame number is bigger than existing file frame count, now guarded . --- MissionEditor/Loading.cpp | 3 +++ MissionEditorPackLib/MissionEditorPackLib.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/MissionEditor/Loading.cpp b/MissionEditor/Loading.cpp index b33de42..663de6a 100644 --- a/MissionEditor/Loading.cpp +++ b/MissionEditor/Loading.cpp @@ -534,6 +534,9 @@ bool CLoading::LoadSingleFrameShape(const CString& name, int nFrame, int deltaX, if (!FSunPackLib::XCC_GetSHPHeader(&header)) { return false; } + if (nFrame >= header.c_images) { + nFrame = 0; + } if (!FSunPackLib::LoadSHPImage(nFrame, 1, &pBuffer)) { return false; } diff --git a/MissionEditorPackLib/MissionEditorPackLib.cpp b/MissionEditorPackLib/MissionEditorPackLib.cpp index 1723b0c..d1f06b2 100644 --- a/MissionEditorPackLib/MissionEditorPackLib.cpp +++ b/MissionEditorPackLib/MissionEditorPackLib.cpp @@ -922,6 +922,9 @@ namespace FSunPackLib if (head.cx == 0 || head.cy == 0) { return FALSE; } + if (startIndex >= head.c_images) { + return FALSE; + } std::vector decode_image_buffer; for (auto frameIdx = 0; frameIdx < wantedNum; frameIdx++) {