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

Unified Diff: src/core/SkBitmap.cpp

Issue 376803004: Adding validation before using an SkImageInfo object read from an SkReadBuffer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added missing check before computing minRowBytes() Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index a40f61af35f333bb73386f459728c2bf60a098c7..651152e703bd5c2e0bf9c31b6f97f9d33abba532 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1201,6 +1201,11 @@ bool SkBitmap::ReadRawPixels(SkReadBuffer* buffer, SkBitmap* bitmap) {
SkImageInfo info;
info.unflatten(*buffer);
+ // If there was an error reading "info", don't use it to compute minRowBytes()
+ if (!buffer->validate(true)) {
+ return false;
+ }
+
const size_t ramRB = info.minRowBytes();
const int height = info.height();
const size_t snugSize = snugRB * height;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698