Skip to content

Commit

Permalink
Cherry-pick 265870.559@safari-7616-branch (8e93326). https://bugs.web…
Browse files Browse the repository at this point in the history
…kit.org/show_bug.cgi?id=261519

    SubtleCrypto:wrapKey ensure promise is not garbage collected
    https://bugs.webkit.org/show_bug.cgi?id=261519
    rdar://115349445

    Reviewed by Tim Nguyen.

    We need to ensure that the promise always remains alive when in use.
    Adding a RefPtr guarantees that it will not be garbage collected.

    * Source/WebCore/crypto/SubtleCrypto.cpp:
    (WebCore::SubtleCrypto::wrapKey):

    Canonical link: https://commits.webkit.org/265870.559@safari-7616-branch
  • Loading branch information
stwrt authored and aperezdc committed Oct 20, 2023
1 parent 778c025 commit 4f150b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Source/WebCore/crypto/SubtleCrypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ void SubtleCrypto::wrapKey(JSC::JSGlobalObject& state, KeyFormat format, CryptoK
WeakPtr weakThis { *this };
auto callback = [index, weakThis, wrapAlgorithm, wrappingKey = Ref { wrappingKey }, wrapParams = WTFMove(wrapParams), isEncryption, context, workQueue = m_workQueue](SubtleCrypto::KeyFormat format, KeyData&& key) mutable {
if (weakThis) {
if (auto promise = weakThis->m_pendingPromises.get(index)) {
if (RefPtr promise = weakThis->m_pendingPromises.get(index)) {
Vector<uint8_t> bytes;
switch (format) {
case SubtleCrypto::KeyFormat::Spki:
Expand Down

0 comments on commit 4f150b6

Please sign in to comment.