src: skip revoke_data_object if uuid is not found

Fix: https://github.com/nodejs/node/issues/42206

PR-URL: https://github.com/nodejs/node/pull/42212
Fixes: https://github.com/nodejs/node/issues/42206
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Xuguang Mei authored and Stewart X Addison committed 2022-03-07 17:44:04 +00:00
1 parent 5b23e67ad5
commit 0abc20b6cf
3 files changed
+9 -2

No files matched your search

+2 -1
View File
@@ -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`
+3 -1
View File
@@ -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());
}
@@ -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