Skip to content

Commit 968454f

Browse files
drWulfandi34
authored andcommitted
Fix overflow when comparing two ints by promoting the sum to 64-bits.
R=reed@google.com, scroggo@google.com Author: djsollen@google.com Review URL: https://codereview.chromium.org/505153003 bug: 17265206 Change-Id: Id74fc6d165b55258dbd980d9d36afe1377e7a162
1 parent 3e9f006 commit 968454f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/images/SkImageDecoder_libico.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
150150
//int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usually 0
151151
const size_t size = read4Bytes(buf, 14 + choice*16); //matters?
152152
const size_t offset = read4Bytes(buf, 18 + choice*16);
153-
if ((offset + size) > length) {
153+
// promote the sum to 64-bits to avoid overflow
154+
if (((uint64_t)offset + size) > length) {
154155
return false;
155156
}
156157

0 commit comments

Comments
 (0)