Index: src/gpu/gl/GrGLCreateNullInterface.cpp |
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp |
index b9a29fb7421d3a117f3768d0a84b6ea613ae454a..80a7cfbd2cdba26465042be242be89925edf01e0 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); |
+ } |
} |
} |