WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-171211-20170425113046.patch (text/plain), 12.29 KB, created by
Miguel Gomez
on 2017-04-25 02:30:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Miguel Gomez
Created:
2017-04-25 02:30:48 PDT
Size:
12.29 KB
patch
obsolete
>Subversion Revision: 215680 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index fd707c90eeaef9754e6622a54f84c2f1d93a62de..2b5328004c2078ba63bbff685c20d5eab6cbb55f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2017-04-25 Miguel Gomez <magomez@igalia.com> >+ >+ Image decoders must have private constructors to avoid refcount misuse: ASSERTION FAILED: m_deletionHasBegun when destroying ImageDecoder >+ https://bugs.webkit.org/show_bug.cgi?id=171211 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a create method to each of the decoders and set their constructors as private. Change >+ ICOImageDecoder to store its internal PNG decoders as RefPtr and use the new create method, and >+ change ImageDecoder to use the create methods as well. >+ >+ Covered by existent tests. >+ >+ * platform/image-decoders/ImageDecoder.cpp: >+ (WebCore::ImageDecoder::create): >+ * platform/image-decoders/bmp/BMPImageDecoder.h: >+ * platform/image-decoders/gif/GIFImageDecoder.h: >+ * platform/image-decoders/ico/ICOImageDecoder.cpp: >+ (WebCore::ICOImageDecoder::decodeAtIndex): >+ * platform/image-decoders/ico/ICOImageDecoder.h: >+ * platform/image-decoders/jpeg/JPEGImageDecoder.h: >+ * platform/image-decoders/png/PNGImageDecoder.h: >+ * platform/image-decoders/webp/WEBPImageDecoder.h: >+ > 2017-04-23 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r215657 and r215676. >diff --git a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp b/Source/WebCore/platform/image-decoders/ImageDecoder.cpp >index baf9e464dc86e8d15f6d5cefea0b3a86971d03f4..a0e1309a0d57f0765884a8e0e70b0e939278ccf2 100644 >--- a/Source/WebCore/platform/image-decoders/ImageDecoder.cpp >+++ b/Source/WebCore/platform/image-decoders/ImageDecoder.cpp >@@ -105,24 +105,24 @@ RefPtr<ImageDecoder> ImageDecoder::create(const SharedBuffer& data, AlphaOption > return nullptr; > > if (matchesGIFSignature(contents)) >- return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return GIFImageDecoder::create(alphaOption, gammaAndColorProfileOption); > > if (matchesPNGSignature(contents)) >- return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return PNGImageDecoder::create(alphaOption, gammaAndColorProfileOption); > > if (matchesICOSignature(contents) || matchesCURSignature(contents)) >- return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return ICOImageDecoder::create(alphaOption, gammaAndColorProfileOption); > > if (matchesJPEGSignature(contents)) >- return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return JPEGImageDecoder::create(alphaOption, gammaAndColorProfileOption); > > #if USE(WEBP) > if (matchesWebPSignature(contents)) >- return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return WEBPImageDecoder::create(alphaOption, gammaAndColorProfileOption); > #endif > > if (matchesBMPSignature(contents)) >- return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ return BMPImageDecoder::create(alphaOption, gammaAndColorProfileOption); > > return nullptr; > } >diff --git a/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h b/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h >index 8e2ebdc50225b05c246f4e12224c60f073c8c9ad..4b907e4bb4fd84419c0a58203ad1469c7c6da85d 100644 >--- a/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h >@@ -37,7 +37,10 @@ namespace WebCore { > // This class decodes the BMP image format. > class BMPImageDecoder final : public ImageDecoder { > public: >- BMPImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new BMPImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } > > // ImageDecoder > String filenameExtension() const override { return "bmp"; } >@@ -50,6 +53,8 @@ namespace WebCore { > bool setFailed() override; > > private: >+ BMPImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > inline uint32_t readUint32(int offset) const > { > return BMPImageReader::readUint32(m_data.get(), m_decodedOffset + offset); >diff --git a/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h b/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h >index ea9aaff43ca60d8ff812f2784fc112757508adb6..fe9386810ee5211e367e3e9b37b91640f89c1d46 100644 >--- a/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h >@@ -35,7 +35,11 @@ namespace WebCore { > // This class decodes the GIF image format. > class GIFImageDecoder final : public ImageDecoder { > public: >- GIFImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new GIFImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } >+ > virtual ~GIFImageDecoder(); > > enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery }; >@@ -60,6 +64,8 @@ namespace WebCore { > void gifComplete(); > > private: >+ GIFImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > // If the query is GIFFullQuery, decodes the image up to (but not > // including) |haltAtFrame|. Otherwise, decodes as much as is needed to > // answer the query, ignoring bitmap data. If decoding fails but there >diff --git a/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp b/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp >index cd8dd4b8353b2b7fb491163f42aa2bdee5533562..b003422d4c71cf57ff20a33adb25cbfa5ac6a798 100644 >--- a/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp >+++ b/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp >@@ -216,9 +216,7 @@ bool ICOImageDecoder::decodeAtIndex(size_t index) > } > > if (!m_pngDecoders[index]) { >- m_pngDecoders[index] = std::make_unique< >- PNGImageDecoder>(m_premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied, >- m_ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied); >+ m_pngDecoders[index] = PNGImageDecoder::create(m_premultiplyAlpha ? AlphaOption::Premultiplied : AlphaOption::NotPremultiplied, m_ignoreGammaAndColorProfile ? GammaAndColorProfileOption::Ignored : GammaAndColorProfileOption::Applied); > setDataForPNGDecoderAtIndex(index); > } > // Fail if the size the PNGImageDecoder calculated does not match the size >diff --git a/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h b/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h >index 36ddb8f78efa57e2c78c41cd0b3a31fb77f3cd85..9adb0b990701cb3c9a73838400d252f47839c69a 100644 >--- a/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/ico/ICOImageDecoder.h >@@ -33,13 +33,14 @@ > #include "BMPImageReader.h" > > namespace WebCore { >- >- class PNGImageDecoder; >- > // This class decodes the ICO and CUR image formats. > class ICOImageDecoder final : public ImageDecoder { > public: >- ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new ICOImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } >+ > virtual ~ICOImageDecoder(); > > // ImageDecoder >@@ -76,6 +77,8 @@ namespace WebCore { > uint32_t m_imageOffset; > }; > >+ ICOImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > // Returns true if |a| is a preferable icon entry to |b|. > // Larger sizes, or greater bitdepths at the same size, are preferable. > static bool compareEntries(const IconDirectoryEntry& a, const IconDirectoryEntry& b); >@@ -141,7 +144,7 @@ namespace WebCore { > // The image decoders for the various frames. > typedef Vector<std::unique_ptr<BMPImageReader>> BMPReaders; > BMPReaders m_bmpReaders; >- typedef Vector<std::unique_ptr<PNGImageDecoder>> PNGDecoders; >+ typedef Vector<RefPtr<ImageDecoder>> PNGDecoders; > PNGDecoders m_pngDecoders; > > // Valid only while a BMPImageReader is decoding, this holds the size >diff --git a/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h b/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h >index 1aeb300b3857ce7f28104b594a6796964978dfb6..6f23b199af2f86b98331926c47ed7f9d0fd77f27 100644 >--- a/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h >@@ -43,7 +43,11 @@ namespace WebCore { > // This class decodes the JPEG image format. > class JPEGImageDecoder final : public ImageDecoder { > public: >- JPEGImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new JPEGImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } >+ > virtual ~JPEGImageDecoder(); > > // ImageDecoder >@@ -68,6 +72,8 @@ namespace WebCore { > void setOrientation(ImageOrientation orientation) { m_orientation = orientation; } > > private: >+ JPEGImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > // Decodes the image. If |onlySize| is true, stops decoding after > // calculating the image size. If decoding fails but there is no more > // data coming, sets the "decode failure" flag. >diff --git a/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h b/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h >index dcdb80c8294e98a72971ef36a998d88da728cf82..dd591a895ef2ed7e51b2c4bba5a64a2bf7ee0b28 100644 >--- a/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h >@@ -37,7 +37,11 @@ namespace WebCore { > // This class decodes the PNG image format. > class PNGImageDecoder final : public ImageDecoder { > public: >- PNGImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new PNGImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } >+ > virtual ~PNGImageDecoder(); > > // ImageDecoder >@@ -85,6 +89,8 @@ namespace WebCore { > } > > private: >+ PNGImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > // Decodes the image. If |onlySize| is true, stops decoding after > // calculating the image size. If decoding fails but there is no more > // data coming, sets the "decode failure" flag. >diff --git a/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h b/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h >index be9795e565abdce1e312993337fe4c306fbdaac0..79f38b5e9d220b76a710690f0649f3c5d22bfb94 100644 >--- a/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h >+++ b/Source/WebCore/platform/image-decoders/webp/WEBPImageDecoder.h >@@ -38,7 +38,11 @@ namespace WebCore { > > class WEBPImageDecoder final : public ImageDecoder { > public: >- WEBPImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ static Ref<ImageDecoder> create(AlphaOption alphaOption, GammaAndColorProfileOption gammaAndColorProfileOption) >+ { >+ return adoptRef(*new WEBPImageDecoder(alphaOption, gammaAndColorProfileOption)); >+ } >+ > virtual ~WEBPImageDecoder(); > > String filenameExtension() const override { return "webp"; } >@@ -46,6 +50,8 @@ public: > ImageFrame* frameBufferAtIndex(size_t index) override; > > private: >+ WEBPImageDecoder(AlphaOption, GammaAndColorProfileOption); >+ > bool decode(bool onlySize); > > WebPIDecoder* m_decoder;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 171211
:
307949
|
307975
| 308078