Merge pull request #3768 from deprekated/fix_privacy_null_deref

fix null-deref due to unconstructed PrivacyNodeInfo
This commit is contained in:
Alexis Rouillard
2024-11-20 09:02:38 +01:00
committed by GitHub

View File

@ -126,6 +126,7 @@ void PipewireBackend::handleRegistryEventGlobal(uint32_t id, uint32_t permission
if (proxy == nullptr) return; if (proxy == nullptr) return;
auto *pNodeInfo = (PrivacyNodeInfo *)pw_proxy_get_user_data(proxy); auto *pNodeInfo = (PrivacyNodeInfo *)pw_proxy_get_user_data(proxy);
new(pNodeInfo) PrivacyNodeInfo{};
pNodeInfo->id = id; pNodeInfo->id = id;
pNodeInfo->data = this; pNodeInfo->data = this;
pNodeInfo->type = mediaType; pNodeInfo->type = mediaType;
@ -142,6 +143,7 @@ void PipewireBackend::handleRegistryEventGlobalRemove(uint32_t id) {
mutex_.lock(); mutex_.lock();
auto iter = privacy_nodes.find(id); auto iter = privacy_nodes.find(id);
if (iter != privacy_nodes.end()) { if (iter != privacy_nodes.end()) {
privacy_nodes[id]->~PrivacyNodeInfo();
privacy_nodes.erase(id); privacy_nodes.erase(id);
} }
mutex_.unlock(); mutex_.unlock();