소스 검색

[cpp] Fix UB in attachment timeline binary parsing

Mario Zechner 1 개월 전
부모
커밋
3e67c82a22
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      spine-cpp/src/spine/SkeletonBinary.cpp

+ 5 - 1
spine-cpp/src/spine/SkeletonBinary.cpp

@@ -805,7 +805,11 @@ Animation *SkeletonBinary::readAnimation(DataInput &input, const String &name, S
 			switch (timelineType) {
 				case SLOT_ATTACHMENT: {
 					AttachmentTimeline *timeline = new (__FILE__, __LINE__) AttachmentTimeline(frameCount, slotIndex);
-					for (int frame = 0; frame < frameCount; ++frame) timeline->setFrame(frame, input.readFloat(), input.readStringRef());
+					for (int frame = 0; frame < frameCount; ++frame) {
+						float time = input.readFloat();
+						char *attachmentName = input.readStringRef();
+						timeline->setFrame(frame, time, attachmentName);
+					}
 					timelines.add(timeline);
 					break;
 				}