File tree 3 files changed +8
-9
lines changed
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) {
82
82
83
83
const auto &frameData = frame.getFrameData ();
84
84
while (process) {
85
+ if (offset >= frameData.size ()) {
86
+ throw std::runtime_error (" Data overrun while decoding DC6 frame." );
87
+ }
85
88
const auto b = frameData[offset];
86
89
offset++;
87
90
@@ -102,6 +105,9 @@ void DC6::setPalette(const Palette &palette) {
102
105
}
103
106
case eScanlineType::RunOfOpaquePixels: {
104
107
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
+ }
105
111
const auto paletteIndex = static_cast <int >(frameData[offset]);
106
112
const auto &paletteColor = palette.getEntries ()[paletteIndex];
107
113
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) {
14
14
_nextBlock = stream.readUInt32 ();
15
15
_length = stream.readUInt32 ();
16
16
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);
22
19
}
23
20
24
21
uint32_t DC6Frame::getFlipped () const { return _flipped; }
@@ -39,6 +36,4 @@ uint32_t DC6Frame::getLength() const { return _length; }
39
36
40
37
const std::vector<std::byte>& DC6Frame::getFrameData () const { return _frameData; }
41
38
42
- const std::vector<std::byte>& DC6Frame::getTerminator () const { return _terminator; }
43
-
44
39
} // namespace Abyss::DataTypes
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ class DC6Frame {
22
22
uint32_t _nextBlock{};
23
23
uint32_t _length{};
24
24
std::vector<std::byte> _frameData{};
25
- std::vector<std::byte> _terminator{};
26
25
27
26
public:
28
27
explicit DC6Frame (Streams::StreamReader& stream);
@@ -35,7 +34,6 @@ class DC6Frame {
35
34
[[nodiscard]] uint32_t getNextBlock () const ;
36
35
[[nodiscard]] uint32_t getLength () const ;
37
36
[[nodiscard]] const std::vector<std::byte>& getFrameData () const ;
38
- [[nodiscard]] const std::vector<std::byte>& getTerminator () const ;
39
37
};
40
38
41
39
} // namespace Abyss::DataTypes
You can’t perform that action at this time.
0 commit comments