Bug 920571 - Don't read from the trailing stride on the last row of pixels when copying image data in SourceSurfaceCG. r=jrmuizel

This commit is contained in:
Matt Woodrow 2013-09-30 14:42:45 +13:00
parent 7fffb0ca44
commit e899730348

View File

@ -127,7 +127,9 @@ SourceSurfaceCG::InitFromData(unsigned char *aData,
assert(aSize.width >= 0 && aSize.height >= 0);
void *data = malloc(aStride * aSize.height);
memcpy(data, aData, aStride * aSize.height);
// Copy all the data except the stride padding on the very last
// row since we can't guarantee that is readable.
memcpy(data, aData, aStride * (aSize.height - 1) + aSize.width);
mFormat = aFormat;
mImage = CreateCGImage(data, data, aSize, aStride, aFormat);
@ -162,7 +164,7 @@ DataSourceSurfaceCG::InitFromData(unsigned char *aData,
}
void *data = malloc(aStride * aSize.height);
memcpy(data, aData, aStride * aSize.height);
memcpy(data, aData, aStride * (aSize.height - 1) + aSize.width);
mFormat = aFormat;
mImage = CreateCGImage(data, data, aSize, aStride, aFormat);