2011-02-15 Gavin Peters <gavinp@chromium.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Feb 2011 13:09:13 +0000 (13:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Feb 2011 13:09:13 +0000 (13:09 +0000)
        Reviewed by Antti Koivisto.

        SharedBuffer::buffer() does not do what you think.
        https://bugs.webkit.org/show_bug.cgi?id=54420

        No new tests.

        * inspector/InspectorResourceAgent.cpp:
        (WebCore::InspectorResourceAgent::resourceContentBase64):
        * platform/SharedBuffer.h:
        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
        (WebCore::JPEGImageReader::decode):
        (WebCore::JPEGImageDecoder::decode):
        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
        (WebCore::WEBPImageDecoder::decode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@78548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.cpp

index 35a4c59..3c63bec 100644 (file)
@@ -1,3 +1,21 @@
+2011-02-15  Gavin Peters  <gavinp@chromium.org>
+
+        Reviewed by Antti Koivisto.
+
+        SharedBuffer::buffer() does not do what you think.
+        https://bugs.webkit.org/show_bug.cgi?id=54420
+
+        No new tests.
+
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::resourceContentBase64):
+        * platform/SharedBuffer.h:
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageReader::decode):
+        (WebCore::JPEGImageDecoder::decode):
+        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
+        (WebCore::WEBPImageDecoder::decode):
+
 2011-02-15  Dirk Schulze  <krit@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
index 38d9e32..f02431e 100644 (file)
@@ -107,7 +107,7 @@ bool InspectorResourceAgent::resourceContentBase64(Frame* frame, const KURL& url
         return false;
     }
 
-    *result = base64Encode(data->buffer());
+    *result = base64Encode(data->data(), data->size());
     return true;
 }
 
index bfc5931..3c92cf3 100644 (file)
@@ -81,10 +81,6 @@ public:
 
     unsigned size() const;
 
-    // Calling this function will force internal segmented buffers
-    // to be merged into a flat buffer. Use getSomeData() whenever possible
-    // for better performance.
-    const Vector<char>& buffer() const;
 
     bool isEmpty() const { return !size(); }
 
@@ -119,6 +115,13 @@ private:
     SharedBuffer(const char*, int);
     SharedBuffer(const unsigned char*, int);
     
+    // Calling this function will force internal segmented buffers
+    // to be merged into a flat buffer. Use getSomeData() whenever possible
+    // for better performance.
+    // As well, be aware that this method does *not* return any purgeable
+    // memory, which can be a source of bugs.
+    const Vector<char>& buffer() const;
+
     void clearPlatformData();
     void maybeTransferPlatformData();
     bool hasPlatformData() const;
index 1434c65..471ab98 100644 (file)
@@ -179,7 +179,7 @@ public:
         m_bytesToSkip = std::max(numBytes - bytesToSkip, static_cast<long>(0));
     }
 
-    bool decode(const Vector<char>& data, bool onlySize)
+    bool decode(const SharedBuffer& data, bool onlySize)
     {
         m_decodingSizeOnly = onlySize;
 
@@ -532,7 +532,7 @@ void JPEGImageDecoder::decode(bool onlySize)
 
     // If we couldn't decode the image but we've received all the data, decoding
     // has failed.
-    if (!m_reader->decode(m_data->buffer(), onlySize) && isAllDataReceived())
+    if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
         setFailed();
     // If we're done decoding the image, we don't need the JPEGImageReader
     // anymore.  (If we failed, |m_reader| has already been cleared.)
index 3db00f6..060c62a 100644 (file)
@@ -79,9 +79,9 @@ bool WEBPImageDecoder::decode(bool onlySize)
 
     if (failed())
         return false;
-    const size_t dataSize = m_data->buffer().size();
+    const size_t dataSize = m_data->size();
     const uint8_t* dataBytes =
-        reinterpret_cast<const uint8_t*>(m_data->buffer().data());
+        reinterpret_cast<const uint8_t*>(m_data->data());
     int width, height;
     if (dataSize < sizeOfHeader)
         return true;