fix null-deref due to unconstructed PrivacyNodeInfo

This would cause Waybar to crash if the privacy module ever got
e.g. a empty (but properly null-terminated) string for the
application_name.
This commit is contained in:
Kate Adkins
2024-11-15 12:04:56 -07:00
parent 8645115619
commit 86ce9f7278

View File

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