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

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 41253002: Checking structure sizes before reading them from memory to avoid overflowing the buffer's stream. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Removing SkMatrix's writeToMemory, readFromMemory Created 7 years, 2 months 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
Index: src/pipe/SkGPipeWrite.cpp
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 57d4a0fdc345ee57263420a44fb08ae19e7d6783..0e7884d801f9c179a51cf15556ef4694cb9d9718 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -609,7 +609,7 @@ bool SkGPipeCanvas::skew(SkScalar sx, SkScalar sy) {
bool SkGPipeCanvas::concat(const SkMatrix& matrix) {
if (!matrix.isIdentity()) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(matrix.writeToMemory(NULL))) {
+ if (this->needOpBytes(fWriter.writeMatrixSize(matrix))) {
this->writeOp(kConcat_DrawOp);
fWriter.writeMatrix(matrix);
}
@@ -619,7 +619,7 @@ bool SkGPipeCanvas::concat(const SkMatrix& matrix) {
void SkGPipeCanvas::setMatrix(const SkMatrix& matrix) {
NOTIFY_SETUP(this);
- if (this->needOpBytes(matrix.writeToMemory(NULL))) {
+ if (this->needOpBytes(fWriter.writeMatrixSize(matrix))) {
this->writeOp(kSetMatrix_DrawOp);
fWriter.writeMatrix(matrix);
}
@@ -801,7 +801,7 @@ void SkGPipeCanvas::drawBitmapRectToRect(const SkBitmap& bm, const SkRect* src,
void SkGPipeCanvas::drawBitmapMatrix(const SkBitmap& bm, const SkMatrix& matrix,
const SkPaint* paint) {
NOTIFY_SETUP(this);
- size_t opBytesNeeded = matrix.writeToMemory(NULL);
+ size_t opBytesNeeded = fWriter.writeMatrixSize(matrix);
if (this->commonDrawBitmap(bm, kDrawBitmapMatrix_DrawOp, 0, opBytesNeeded, paint)) {
fWriter.writeMatrix(matrix);
@@ -891,7 +891,7 @@ void SkGPipeCanvas::drawTextOnPath(const void* text, size_t byteLength,
size_t size = 4 + SkAlign4(byteLength) + path.writeToMemory(NULL);
if (matrix) {
flags |= kDrawTextOnPath_HasMatrix_DrawOpFlag;
- size += matrix->writeToMemory(NULL);
+ size += fWriter.writeMatrixSize(*matrix);
}
this->writePaint(paint);
if (this->needOpBytes(size)) {

Powered by Google App Engine
This is Rietveld 408576698