File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,9 @@ void DC6::setPalette(const Palette &palette) {
8282
8383 const auto &frameData = frame.getFrameData ();
8484 while (process) {
85+ if (offset >= frameData.size ()) {
86+ throw std::runtime_error (" Data overrun while decoding DC6 frame." );
87+ }
8588 const auto b = frameData[offset];
8689 offset++;
8790
@@ -102,6 +105,9 @@ void DC6::setPalette(const Palette &palette) {
102105 }
103106 case eScanlineType::RunOfOpaquePixels: {
104107 for (auto i = 0 ; i < static_cast <int >(b); i++) {
108+ if (offset >= frameData.size ()) {
109+ throw std::runtime_error (" Data overrun while decoding DC6 frame." );
110+ }
105111 const auto paletteIndex = static_cast <int >(frameData[offset]);
106112 const auto &paletteColor = palette.getEntries ()[paletteIndex];
107113 const auto pixel = static_cast <uint32_t >(paletteColor.getBlue () << 24 | paletteColor.getGreen () << 16 | paletteColor.getRed () << 8 | 0xFF );
Original file line number Diff line number Diff line change @@ -14,11 +14,8 @@ DC6Frame::DC6Frame(Streams::StreamReader &stream) {
1414 _nextBlock = stream.readUInt32 ();
1515 _length = stream.readUInt32 ();
1616
17- _frameData.resize (_length);
18- stream.readBytes (_frameData);
19-
20- _terminator.resize (DC6TerminatorSize);
21- stream.readBytes (_terminator);
17+ _frameData.resize (_length + DC6TerminatorSize);
18+ stream.readBytes (_frameData);
2219}
2320
2421uint32_t DC6Frame::getFlipped () const { return _flipped; }
@@ -39,6 +36,4 @@ uint32_t DC6Frame::getLength() const { return _length; }
3936
4037const std::vector<std::byte>& DC6Frame::getFrameData () const { return _frameData; }
4138
42- const std::vector<std::byte>& DC6Frame::getTerminator () const { return _terminator; }
43-
4439} // namespace Abyss::DataTypes
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ class DC6Frame {
2222 uint32_t _nextBlock{};
2323 uint32_t _length{};
2424 std::vector<std::byte> _frameData{};
25- std::vector<std::byte> _terminator{};
2625
2726 public:
2827 explicit DC6Frame (Streams::StreamReader& stream);
@@ -35,7 +34,6 @@ class DC6Frame {
3534 [[nodiscard]] uint32_t getNextBlock () const ;
3635 [[nodiscard]] uint32_t getLength () const ;
3736 [[nodiscard]] const std::vector<std::byte>& getFrameData () const ;
38- [[nodiscard]] const std::vector<std::byte>& getTerminator () const ;
3937};
4038
4139} // namespace Abyss::DataTypes
You can’t perform that action at this time.
0 commit comments