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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp

Issue 2173873003: Cancel image loads if decoding failed (attempt #2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix UAF Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/gpu/WebGLImageConversion.h" 5 #include "platform/graphics/gpu/WebGLImageConversion.h"
6 6
7 #include "platform/CheckedInt.h" 7 #include "platform/CheckedInt.h"
8 #include "platform/graphics/ImageObserver.h" 8 #include "platform/graphics/ImageObserver.h"
9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h"
10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h" 10 #include "platform/graphics/cpu/x86/WebGLImageConversionSSE.h"
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame(); 2135 RefPtr<SkImage> skiaImage = m_image->imageForCurrentFrame();
2136 SkImageInfo info = skiaImage 2136 SkImageInfo info = skiaImage
2137 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height()) 2137 ? SkImageInfo::MakeN32Premul(m_image->width(), m_image->height())
2138 : SkImageInfo::MakeUnknown(); 2138 : SkImageInfo::MakeUnknown();
2139 m_alphaOp = AlphaDoNothing; 2139 m_alphaOp = AlphaDoNothing;
2140 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true; 2140 bool hasAlpha = skiaImage ? !skiaImage->isOpaque() : true;
2141 2141
2142 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl pha)) && m_image->data()) { 2142 if ((!skiaImage || ignoreGammaAndColorProfile || (hasAlpha && !premultiplyAl pha)) && m_image->data()) {
2143 // Attempt to get raw unpremultiplied image data. 2143 // Attempt to get raw unpremultiplied image data.
2144 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create( 2144 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(
2145 *(m_image->data()), ImageDecoder::AlphaNotPremultiplied, 2145 ImageDecoder::determineImageType(*(m_image->data())), ImageDecoder:: AlphaNotPremultiplied,
2146 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor ed : ImageDecoder::GammaAndColorProfileApplied)); 2146 ignoreGammaAndColorProfile ? ImageDecoder::GammaAndColorProfileIgnor ed : ImageDecoder::GammaAndColorProfileApplied));
2147 if (!decoder) 2147 if (!decoder)
2148 return; 2148 return;
2149 decoder->setData(m_image->data(), true); 2149 decoder->setData(m_image->data(), true);
2150 if (!decoder->frameCount()) 2150 if (!decoder->frameCount())
2151 return; 2151 return;
2152 ImageFrame* frame = decoder->frameBufferAtIndex(0); 2152 ImageFrame* frame = decoder->frameBufferAtIndex(0);
2153 if (!frame || frame->getStatus() != ImageFrame::FrameComplete) 2153 if (!frame || frame->getStatus() != ImageFrame::FrameComplete)
2154 return; 2154 return;
2155 hasAlpha = frame->hasAlpha(); 2155 hasAlpha = frame->hasAlpha();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 } 2405 }
2406 2406
2407 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride); 2407 FormatConverter converter(width, height, sourceData, destinationData, srcStr ide, dstStride);
2408 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); 2408 converter.convert(sourceDataFormat, dstDataFormat, alphaOp);
2409 if (!converter.Success()) 2409 if (!converter.Success())
2410 return false; 2410 return false;
2411 return true; 2411 return true;
2412 } 2412 }
2413 2413
2414 } // namespace blink 2414 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698