Skip to content

Commit ae64a20

Browse files
jzoranandi34
authored andcommitted
SkScaledBitmapSampler: fix memory overwritten
Cherry-picked from https://codereview.chromium.org/1085253002 in Skia. Memory will be overwritten while downsampling some interlaced gif images, most commonly with odd sizes, when index of destination row stores in the current line computed from GifInterlaceIter meets: X is an integer in [0..height-1] and (X < height) && ((X - sampleSize/2) % sampleSize == 0) && ((X - sampleSize/2)/sampleSize >= height/sampleSize) Signed-off-by: Lu Tong <lu.x.tong@sonymobile.com> BUG=skia: Review URL: https://codereview.chromium.org/1085253002 CVE-2015-3877 BUG:20723696 Change-Id: I2cca83a2a5c39b5a497f36b40724262b438ead8b
1 parent 54d95a3 commit ae64a20

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/images/SkScaledBitmapSampler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,9 @@ bool SkScaledBitmapSampler::sampleInterlaced(const uint8_t* SK_RESTRICT src, int
745745
// of the destination bitmap's pixels, which is used to calculate the destination row
746746
// each time this function is called.
747747
const int dstY = srcYMinusY0 / fDY;
748-
SkASSERT(dstY < fScaledHeight);
748+
if (dstY >= fScaledHeight) {
749+
return false;
750+
}
749751
char* dstRow = fDstRow + dstY * fDstRowBytes;
750752
return fRowProc(dstRow, src + fX0 * fSrcPixelSize, fScaledWidth,
751753
fDX * fSrcPixelSize, dstY, fCTable);

0 commit comments

Comments
 (0)