From: cdalton Date: Wed, 6 Apr 2016 20:36:38 +0000 (-0700) Subject: Fix null context GenBuffers X-Git-Tag: submit/tizen/20180928.044319~129^2~1099 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a957b8a114bb003d0975a5d5737c30b00e5940ab;p=platform%2Fupstream%2FlibSkiaSharp.git Fix null context GenBuffers Fixes the null context to not return 0 for GenBuffers. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1863923003 Review URL: https://codereview.chromium.org/1863923003 --- diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index b9a29fb742..80a7cfbd2c 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -47,7 +47,9 @@ private: // This class maintains a sparsely populated array of buffer pointers. class BufferManager { public: - BufferManager() : fFreeListHead(kFreeListEnd) {} + BufferManager() : fFreeListHead(kFreeListEnd) { + *fBuffers.append() = nullptr; // 0 is not a valid GL buffer id. + } ~BufferManager() { // nullptr out the entries that are really free list links rather than ptrs before deleting. @@ -89,6 +91,7 @@ public: } void free(BufferObj* buffer) { + SkASSERT(buffer); SkASSERT(fBuffers.count() > 0); GrGLuint id = buffer->id(); @@ -201,8 +204,10 @@ public: fCurrPixelUnpackBuffer = 0; } - BufferObj* buffer = fBufferManager.lookUp(ids[i]); - fBufferManager.free(buffer); + if (ids[i] > 0) { + BufferObj* buffer = fBufferManager.lookUp(ids[i]); + fBufferManager.free(buffer); + } } }