⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 290152 in webkit


Ignore:
Timestamp:
Feb 18, 2022, 12:27:21 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Keep promise in scope when calling DeferredPromise::reject
​https://bugs.webkit.org/show_bug.cgi?id=236454

Patch by Gabriel Nava Marino <​gnavamarino@apple.com> on 2022-02-18
Reviewed by Darin Adler.

Keep promise in scope when calling DeferredPromise::reject, as createDOMException
could go through a path that invokes GC on its owner and the promise.

  • Modules/fetch/FetchBodyConsumer.cpp:

(WebCore::FetchBodyConsumer::resolveWithFormData):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r290151 r290152  
     12022-02-18  Gabriel Nava Marino  <gnavamarino@apple.com>
     2
     3        Keep promise in scope when calling DeferredPromise::reject
     4        https://bugs.webkit.org/show_bug.cgi?id=236454
     5
     6        Reviewed by Darin Adler.
     7
     8        Keep promise in scope when calling DeferredPromise::reject, as createDOMException
     9        could go through a path that invokes GC on its owner and the promise.
     10
     11        * Modules/fetch/FetchBodyConsumer.cpp:
     12        (WebCore::FetchBodyConsumer::resolveWithFormData):
     13
    1142022-02-18  Tim Horton  <timothy_horton@apple.com>
    215
  • trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp

    r287877 r290152  
    270270        return;
    271271
    272     m_formDataConsumer = makeUnique<FormDataConsumer>(formData, *context, [this, promise = WTFMove(promise), contentType, builder = SharedBufferBuilder { }](auto&& result) mutable {
     272    m_formDataConsumer = makeUnique<FormDataConsumer>(formData, *context, [this, capturedPromise = WTFMove(promise), contentType, builder = SharedBufferBuilder { }](auto&& result) mutable {
    273273        if (result.hasException()) {
     274            auto promise = WTFMove(capturedPromise);
    274275            promise->reject(result.releaseException());
    275276            return;
    … …  
    279280        if (value.empty()) {
    280281            auto buffer = builder.takeAsContiguous();
    281             resolveWithData(WTFMove(promise), contentType, buffer->data(), buffer->size());
     282            resolveWithData(WTFMove(capturedPromise), contentType, buffer->data(), buffer->size());
    282283            return;
    283284        }
Note: See TracChangeset for help on using the changeset viewer.