fix: clean up base::LinkedList in context_bridge::ObjectCache (#27630)

base::LinkedList does not delete its members on destruction. We need to
manually ensure the linkedlist is empty when the ObjectCache is
destroyed.

Fixes #27039

Notes: Fixed memory leak when sending non-primitives over the context
bridge
This commit is contained in:
Samuel Attard 2021-02-05 12:39:05 -08:00 committed by GitHub
parent d06bb7c97b
commit b6a91ef5df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,15 @@ ObjectCachePairNode::ObjectCachePairNode(ObjectCachePair&& pair) {
ObjectCachePairNode::~ObjectCachePairNode() = default;
ObjectCache::ObjectCache() {}
ObjectCache::~ObjectCache() = default;
ObjectCache::~ObjectCache() {
for (const auto& pair : proxy_map_) {
while (!pair.second.empty()) {
ObjectCachePairNode* node = pair.second.head()->value();
node->RemoveFromList();
delete node;
}
}
}
void ObjectCache::CacheProxiedObject(v8::Local<v8::Value> from,
v8::Local<v8::Value> proxy_value) {