Add an assert that we still have a buffer to readFromBuffer().
sk_free(fBuffer.detach()) means fBuffer will be left as NULL, not a zero-length malloc.
BUG=skia:
Review URL: https://codereview.chromium.org/669813002
diff --git a/src/utils/SkFrontBufferedStream.cpp b/src/utils/SkFrontBufferedStream.cpp
index 8cb3931..9a666dc 100644
--- a/src/utils/SkFrontBufferedStream.cpp
+++ b/src/utils/SkFrontBufferedStream.cpp
@@ -119,6 +119,7 @@
size_t FrontBufferedStream::bufferAndWriteTo(char* dst, size_t size) {
SkASSERT(size > 0);
SkASSERT(fOffset >= fBufferedSoFar);
+ SkASSERT(fBuffer);
// Data needs to be buffered. Buffer up to the lesser of the size requested
// and the remainder of the max buffer size.
const size_t bytesToBuffer = SkTMin(size, fBufferSize - fBufferedSoFar);
@@ -148,7 +149,7 @@
// If we have read past the end of the buffer, rewinding is no longer
// supported, so we can go ahead and free the memory.
if (bytesReadDirectly > 0) {
- fBuffer.reset(0);
+ sk_free(fBuffer.detach());
}
return bytesReadDirectly;