[Webkit-unassigned] [Bug 162608] [GTK] Update WOFF2 decoder

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 28 02:44:05 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=162608

--- Comment #10 from Khaled Hosny <khaledhosny at eglug.org> ---
Comment on attachment 289962
  --> https://bugs.webkit.org/attachment.cgi?id=289962
Patch, v3

View in context: https://bugs.webkit.org/attachment.cgi?id=289962&action=review

>> Source/WebCore/platform/graphics/WOFFFileFormat.cpp:125
>> +    Vector<char>& m_vector;
> 
> Optional: I think it would be safer to keep a plain Vector<char> here instead of a reference, and sink it to WOFF2VectorOut by changing the constructor to take a Vector<char>&& instead of a Vector<char>. Then you will need to use WTFMove to pass the vector to the constructor. The advantage of doing it that way is the WOFF2VectorOut becomes harder to misuse (more robust to future modification); currently it breaks badly if the passed in vector goes out of scope before the WOFF2VectorOut does. But this is optional; the current way is OK too.

I tried doing that, but then nothing was written to the `sfnt` vector, not sure if I’m doing something wrong:
diff --git a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
index c2323cf..60eb7df 100644
--- a/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
+++ b/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
@@ -93,8 +93,8 @@ bool isWOFF(SharedBuffer& buffer)
 #if USE(WOFF2)
 class WOFF2VectorOut : public woff2::WOFF2Out {
 public:
-    WOFF2VectorOut(Vector<char>& vector)
-        : m_vector(vector)
+    WOFF2VectorOut(Vector<char>&& vector)
+        : m_vector(WTFMove(vector))
     { }

     bool Write(const void* data, size_t n) override
@@ -122,7 +122,7 @@ public:
     }

 private:
-    Vector<char>& m_vector;
+    Vector<char> m_vector;
 };
 #endif

@@ -148,7 +148,7 @@ bool convertWOFFToSfnt(SharedBuffer& woff, Vector<char>& sfnt)
         if (!sfnt.tryReserveCapacity(sfntSize))
             return false;

-        WOFF2VectorOut out(sfnt);
+        WOFF2VectorOut out(WTFMove(sfnt));
         return woff2::ConvertWOFF2ToTTF(woffData, woffSize, &out);
     }
 #endif

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160928/5b62ff4b/attachment.html>


More information about the webkit-unassigned mailing list