diff options
author | 2017-07-12 08:24:56 -0400 | |
---|---|---|
committer | 2017-07-12 12:53:35 +0000 | |
commit | 0f9927712ad8360e45fa20f9726ad14c4b50a85f (patch) | |
tree | 17e55279fdc5c80ff515f4487cb7544482901e45 /src/gpu | |
parent | 590533f066035a48df9f78395a80314b559f4714 (diff) |
Address ASAN complaint
TBR=bsalomon@google.com
Change-Id: Ic3b1f328a84d58939ff55b38cbc1fd4bd29ad5c6
Reviewed-on: https://skia-review.googlesource.com/22482
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-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); |