Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: src/core/SkBuffer.h

Issue 61913002: Adding error checks to SkRBuffer (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added doc Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkFlattenableBuffers.h ('k') | src/core/SkBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBuffer.h
diff --git a/src/core/SkBuffer.h b/src/core/SkBuffer.h
index 1a4c6c281c32634dd055abdc765c44af470698c7..369d9c02ac858fd63db81b39595618f88411e0f4 100644
--- a/src/core/SkBuffer.h
+++ b/src/core/SkBuffer.h
@@ -56,23 +56,31 @@ public:
/** Read the specified number of bytes from the data pointer. If buffer is not
null, copy those bytes into buffer.
*/
- virtual void read(void* buffer, size_t size) {
+ virtual bool read(void* buffer, size_t size) {
if (size) {
this->readNoSizeCheck(buffer, size);
}
+ return true;
}
const void* skip(size_t size); // return start of skipped data
size_t skipToAlign4();
- void* readPtr() { void* ptr; read(&ptr, sizeof(ptr)); return ptr; }
- SkScalar readScalar() { SkScalar x; read(&x, 4); return x; }
- uint32_t readU32() { uint32_t x; read(&x, 4); return x; }
- int32_t readS32() { int32_t x; read(&x, 4); return x; }
- uint16_t readU16() { uint16_t x; read(&x, 2); return x; }
- int16_t readS16() { int16_t x; read(&x, 2); return x; }
- uint8_t readU8() { uint8_t x; read(&x, 1); return x; }
- bool readBool() { return this->readU8() != 0; }
+ bool readPtr(void** ptr) { return read(ptr, sizeof(void*)); }
+ bool readScalar(SkScalar* x) { return read(x, 4); }
+ bool readU32(uint32_t* x) { return read(x, 4); }
+ bool readS32(int32_t* x) { return read(x, 4); }
+ bool readU16(uint16_t* x) { return read(x, 2); }
+ bool readS16(int16_t* x) { return read(x, 2); }
+ bool readU8(uint8_t* x) { return read(x, 1); }
+ bool readBool(bool* x) {
+ uint8_t u8;
+ if (this->readU8(&u8)) {
+ *x = (u8 != 0);
+ return true;
+ }
+ return false;
+ }
protected:
void readNoSizeCheck(void* buffer, size_t size);
@@ -95,7 +103,7 @@ public:
null and the number of bytes to read does not overflow this object's data,
copy those bytes into buffer.
*/
- virtual void read(void* buffer, size_t size) SK_OVERRIDE;
+ virtual bool read(void* buffer, size_t size) SK_OVERRIDE;
/** Returns whether or not a read operation attempted to read past the end of the data.
*/
« no previous file with comments | « include/core/SkFlattenableBuffers.h ('k') | src/core/SkBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698