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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 1571233003: Fix errors caused by unsafe conversions to/from size_t (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improved ALLOW_NUMERIC_ARG_TYPES_PROMOTABLE_TO Created 4 years, 11 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: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
index b660c660eb881bd73c788b7b7b1f43c765f20169..b1cac4d49cf6f40825fc7d431b401caa3a8a4955 100644
--- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
@@ -32,12 +32,12 @@
namespace blink {
-static unsigned copyFromSharedBuffer(char* buffer, unsigned bufferLength, const SharedBuffer& sharedBuffer, unsigned offset)
+static size_t copyFromSharedBuffer(char* buffer, size_t bufferLength, const SharedBuffer& sharedBuffer, size_t offset)
{
- unsigned bytesExtracted = 0;
+ size_t bytesExtracted = 0;
const char* moreData;
- while (unsigned moreDataLength = sharedBuffer.getSomeData(moreData, offset)) {
- unsigned bytesToCopy = std::min(bufferLength - bytesExtracted, moreDataLength);
+ while (size_t moreDataLength = sharedBuffer.getSomeData(moreData, offset)) {
+ size_t bytesToCopy = std::min(bufferLength - bytesExtracted, moreDataLength);
memcpy(buffer + bytesExtracted, moreData, bytesToCopy);
bytesExtracted += bytesToCopy;
if (bytesExtracted == bufferLength)
@@ -84,7 +84,7 @@ inline bool matchesBMPSignature(char* contents)
PassOwnPtr<ImageDecoder> ImageDecoder::create(const SharedBuffer& data, AlphaOption alphaOption, GammaAndColorProfileOption colorOptions)
{
- const unsigned longestSignatureLength = sizeof("RIFF????WEBPVP") - 1;
+ const size_t longestSignatureLength = sizeof("RIFF????WEBPVP") - 1;
ASSERT(longestSignatureLength == 14);
size_t maxDecodedBytes = Platform::current() ? Platform::current()->maxDecodedImageBytes() : noDecodedImageByteLimit;

Powered by Google App Engine
This is Rietveld 408576698