Changeset 272845 in webkit


Ignore:
Timestamp:
Feb 15, 2021, 2:38:30 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Crash in RetainPtr<CGImage*>::RetainPtr via ImageBufferCGBackend::toCFData
https://bugs.webkit.org/show_bug.cgi?id=221376

Patch by Frederic Wang <fwang@igalia.com> on 2021-02-15
Reviewed by Said Abou-Hallawa.

Source/WebCore:

Call to copyNativeImage(CopyBackingStore) may return a null pointer if CGBitmapContextCreateImage
does. This patch fixes a crash due to null pointer dereference and adds a similar check for
copyNativeImage(DontCopyBackingStore).

Test: fast/canvas/resize-to-large-canvas-and-convert-to-blog.html

  • platform/graphics/cg/ImageBufferCGBackend.cpp:

(WebCore::ImageBufferCGBackend::toCFData const):

LayoutTests:

  • fast/canvas/resize-to-large-canvas-and-convert-to-blog-expected.txt: Added.
  • fast/canvas/resize-to-large-canvas-and-convert-to-blog-expected.txt: Added.
  • fast/canvas/resize-to-large-canvas-and-convert-to-blog.html: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272842 r272845  
     12021-02-15  Frederic Wang  <fwang@igalia.com>
     2
     3        Crash in RetainPtr<CGImage*>::RetainPtr via ImageBufferCGBackend::toCFData
     4        https://bugs.webkit.org/show_bug.cgi?id=221376
     5
     6        Reviewed by Said Abou-Hallawa.
     7
     8        * fast/canvas/resize-to-large-canvas-and-convert-to-blog-expected.txt: Added.
     9        * fast/canvas/resize-to-large-canvas-and-convert-to-blog-expected.txt: Added.
     10        * fast/canvas/resize-to-large-canvas-and-convert-to-blog.html: Added.
     11
    1122021-02-14  Peng Liu  <peng.liu6@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r272844 r272845  
     12021-02-15  Frederic Wang  <fwang@igalia.com>
     2
     3        Crash in RetainPtr<CGImage*>::RetainPtr via ImageBufferCGBackend::toCFData
     4        https://bugs.webkit.org/show_bug.cgi?id=221376
     5
     6        Reviewed by Said Abou-Hallawa.
     7
     8        Call to copyNativeImage(CopyBackingStore) may return a null pointer if CGBitmapContextCreateImage
     9        does. This patch fixes a crash due to null pointer dereference and adds a similar check for
     10        copyNativeImage(DontCopyBackingStore).
     11
     12        Test: fast/canvas/resize-to-large-canvas-and-convert-to-blog.html
     13
     14        * platform/graphics/cg/ImageBufferCGBackend.cpp:
     15        (WebCore::ImageBufferCGBackend::toCFData const):
     16
    1172021-02-15  Manuel Rego Casasnovas  <rego@igalia.com>
    218
  • trunk/Source/WebCore/platform/graphics/cg/ImageBufferCGBackend.cpp

    r271441 r272845  
    192192        image = adoptCF(CGImageCreate(pixelArrayDimensions.width(), pixelArrayDimensions.height(), 8, 32, 4 * pixelArrayDimensions.width(), sRGBColorSpaceRef(), kCGBitmapByteOrderDefault | kCGImageAlphaNoneSkipLast, dataProvider.get(), 0, false, kCGRenderingIntentDefault));
    193193    } else if (resolutionScale() == 1 || preserveResolution == PreserveResolution::Yes) {
    194         image = copyNativeImage(CopyBackingStore)->platformImage();
     194        auto nativeImage = copyNativeImage(CopyBackingStore);
     195        if (!nativeImage)
     196            return nullptr;
     197        image = nativeImage->platformImage();
    195198        image = createCroppedImageIfNecessary(image.get(), backendSize());
    196199    } else {
    197         image = copyNativeImage(DontCopyBackingStore)->platformImage();
     200        auto nativeImage = copyNativeImage(DontCopyBackingStore);
     201        if (!nativeImage)
     202            return nullptr;
     203        image = nativeImage->platformImage();
    198204        auto context = adoptCF(CGBitmapContextCreate(0, backendSize().width(), backendSize().height(), 8, 4 * backendSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
    199205        CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
Note: See TracChangeset for help on using the changeset viewer.