diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 8 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 7d169ff444..e85b34cab1 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1038,8 +1038,12 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight // Rather than flip in place and alter the incoming data, // we allocate a new buffer to flip into. // This means we need to make a non-const shallow copy of texels. - SkAutoTMalloc<GrMipLevel> texelsShallowCopy(mipLevelCount); - memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel)); + SkAutoTMalloc<GrMipLevel> texelsShallowCopy; + + if (mipLevelCount) { + texelsShallowCopy.reset(mipLevelCount); + memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel)); + } for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; ++currentMipLevel) { SkASSERT(texelsShallowCopy[currentMipLevel].fPixels); diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 87970b5e1c..17fccfb1bb 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -642,8 +642,12 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, // texels is const. // But we may need to adjust the fPixels ptr based on the copyRect, or fRowBytes. // Because of this we need to make a non-const shallow copy of texels. - SkAutoTMalloc<GrMipLevel> texelsShallowCopy(mipLevelCount); - memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel)); + SkAutoTMalloc<GrMipLevel> texelsShallowCopy; + + if (mipLevelCount) { + texelsShallowCopy.reset(mipLevelCount); + memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel)); + } for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; ++currentMipLevel) { SkASSERT(texelsShallowCopy[currentMipLevel].fPixels); |