Skip to content

Commit 0abc20b

Browse files
meixgsxa
authored andcommitted
src: skip revoke_data_object if uuid is not found
Fix: #42206 PR-URL: #42212 Fixes: #42206 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 5b23e67 commit 0abc20b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

doc/api/url.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ added: v16.7.0
659659
* `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to
660660
`URL.createObjectURL()`.
661661

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

664665
### Class: `URLSearchParams`
665666

src/node_blob.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,9 @@ void BlobBindingData::store_data_object(
444444
}
445445

446446
void BlobBindingData::revoke_data_object(const std::string& uuid) {
447-
CHECK_NE(data_objects_.find(uuid), data_objects_.end());
447+
if (data_objects_.find(uuid) == data_objects_.end()) {
448+
return;
449+
}
448450
data_objects_.erase(uuid);
449451
CHECK_EQ(data_objects_.find(uuid), data_objects_.end());
450452
}

test/parallel/test-blob-createobjecturl.js

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const assert = require('assert');
2929
Buffer.from(await otherBlob.arrayBuffer()).toString(),
3030
'hello');
3131
URL.revokeObjectURL(id);
32+
33+
// should do nothing
34+
URL.revokeObjectURL(id);
35+
3236
assert.strictEqual(resolveObjectURL(id), undefined);
3337

3438
// Leaving a Blob registered should not cause an assert

0 commit comments

Comments
 (0)