Skip to content

Commit a7e6c47

Browse files
committed
Add bounds check. Fixes syoyo#177
1 parent df44aa0 commit a7e6c47

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed
952 Bytes
Binary file not shown.
1.85 KB
Binary file not shown.

tinyexr.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -4118,12 +4118,13 @@ static bool DecodePixelData(/* out */ unsigned char **out_images,
41184118
(size_t(height) - 1 - (size_t(y) + v)) * size_t(x_stride);
41194119
}
41204120

4121+
if (reinterpret_cast<const unsigned char *>(line_ptr + width) >
4122+
(data_ptr + data_len)) {
4123+
// Corrupsed data
4124+
return false;
4125+
}
4126+
41214127
for (int u = 0; u < width; u++) {
4122-
if (reinterpret_cast<const unsigned char *>(line_ptr + u) >=
4123-
(data_ptr + data_len)) {
4124-
// Corrupsed data?
4125-
return false;
4126-
}
41274128

41284129
unsigned int val;
41294130
tinyexr::cpy4(&val, line_ptr + u);

0 commit comments

Comments
 (0)