Fixed clusterfuzz found crash
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 13 Feb 2014 18:46:13 +0000 (18:46 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 13 Feb 2014 18:46:13 +0000 (18:46 +0000)
BUG=343461
R=senorblanco@google.com, senorblanco@chromium.org, reed@chromium.org, reed@google.com

Author: sugoi@chromium.org

Review URL: https://codereview.chromium.org/162943003

git-svn-id: http://skia.googlecode.com/svn/trunk@13439 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBitmap.cpp

index 96d683c..3418fad 100644 (file)
@@ -1566,11 +1566,13 @@ void SkBitmap::unflatten(SkReadBuffer& buffer) {
     SkImageInfo info;
     info.unflatten(buffer);
     size_t rowBytes = buffer.readInt();
-    buffer.validate((info.width() >= 0) && (info.height() >= 0) &&
-                    SkColorTypeIsValid(info.fColorType) &&
-                    SkAlphaTypeIsValid(info.fAlphaType) &&
-                    validate_alphaType(info.fColorType, info.fAlphaType) &&
-                    info.validRowBytes(rowBytes));
+    if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) &&
+                         SkColorTypeIsValid(info.fColorType) &&
+                         SkAlphaTypeIsValid(info.fAlphaType) &&
+                         validate_alphaType(info.fColorType, info.fAlphaType) &&
+                         info.validRowBytes(rowBytes))) {
+        return;
+    }
 
     bool configIsValid = this->setConfig(info, rowBytes);
     buffer.validate(configIsValid);