SkASSERT firing because pointer wraps negative.
Some pointers are being cast to intptr_t so they can be used with
SkAlign8(). However, a large pointer value might become a negative
integer since intptr_t is signed.
When comparing these intptr_ts, we expect the larger pointer value to be
greater. But it might be so large that it becomes negative, causing it
to be less than.
A SkASSERT is firing for this exact reason.
BUG=648452
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2353453004
Review-Url: https://codereview.chromium.org/2353453004
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 55fb47a..f8e3b94 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -409,7 +409,7 @@
class DTIBufferFiller
{
public:
- explicit DTIBufferFiller(intptr_t bufferAsInt)
+ explicit DTIBufferFiller(uintptr_t bufferAsInt)
: bufferAsInt_(bufferAsInt) {}
void fillMember(const void* source, size_t memberOffset, size_t size) {
@@ -418,7 +418,7 @@
private:
- intptr_t bufferAsInt_;
+ uintptr_t bufferAsInt_;
};
}
@@ -552,8 +552,8 @@
if (!fillMode) {
return size;
}
- intptr_t bufferAsInt = reinterpret_cast<intptr_t>(buffer);
- intptr_t pixelsAsInt = bufferAsInt + pixelOffset;
+ uintptr_t bufferAsInt = reinterpret_cast<uintptr_t>(buffer);
+ uintptr_t pixelsAsInt = bufferAsInt + pixelOffset;
void* pixels = reinterpret_cast<void*>(pixelsAsInt);
void* ct = nullptr;
if (ctSize) {
@@ -604,7 +604,7 @@
}
// Fill in the mipmap levels if they exist
- intptr_t mipLevelPtr = pixelsAsInt + SkAlign8(pixmap.getSafeSize());
+ uintptr_t mipLevelPtr = pixelsAsInt + SkAlign8(pixmap.getSafeSize());
if (useMipMaps) {
static_assert(std::is_standard_layout<MipMapLevelData>::value,