Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: skip revoke_data_object if uuid is not found #42212

Merged
merged 1 commit into from Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/url.md
Expand Up @@ -659,7 +659,8 @@ added: v16.7.0
* `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to
`URL.createObjectURL()`.

Removes the stored {Blob} identified by the given ID.
Removes the stored {Blob} identified by the given ID. Attempting to revoke a
ID that isn’t registered will silently fail.

### Class: `URLSearchParams`

Expand Down
4 changes: 3 additions & 1 deletion src/node_blob.cc
Expand Up @@ -444,7 +444,9 @@ void BlobBindingData::store_data_object(
}

void BlobBindingData::revoke_data_object(const std::string& uuid) {
CHECK_NE(data_objects_.find(uuid), data_objects_.end());
if (data_objects_.find(uuid) == data_objects_.end()) {
return;
}
data_objects_.erase(uuid);
CHECK_EQ(data_objects_.find(uuid), data_objects_.end());
}
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-blob-createobjecturl.js
Expand Up @@ -29,6 +29,10 @@ const assert = require('assert');
Buffer.from(await otherBlob.arrayBuffer()).toString(),
'hello');
URL.revokeObjectURL(id);

// should do nothing
URL.revokeObjectURL(id);

assert.strictEqual(resolveObjectURL(id), undefined);

// Leaving a Blob registered should not cause an assert
Expand Down