From 0d955a96549b3a83d3876aa7e62817807c3160e2 Mon Sep 17 00:00:00 2001
From: meizhigang <meizhigang@kylinsec.com.cn>
Date: Fri, 14 Apr 2023 09:51:40 +0800
Subject: [PATCH] fix(audio):Fix coredump problem caused by nullpointer to
 string
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - 修复由于赋值string为nullptr导致的崩溃

Signed-off-by: meizhigang <meizhigang@kylinsec.com.cn>
---
 plugins/audio/pulse/pulse-node.cpp | 11 +++++++++++
 plugins/audio/pulse/pulse-node.h   |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/plugins/audio/pulse/pulse-node.cpp b/plugins/audio/pulse/pulse-node.cpp
index 912a811..eac7dfe 100644
--- a/plugins/audio/pulse/pulse-node.cpp
+++ b/plugins/audio/pulse/pulse-node.cpp
@@ -130,6 +130,17 @@ uint32_t PulseNode::get_base_volume()
     return uint32_t(PA_VOLUME_NORM);
 }
 
+std::string PulseNode::get_property(const std::string &key)
+{
+    auto iter = this->attrs_.find(key);
+    if (iter != this->attrs_.end())
+    {
+        return iter->second;
+    }
+
+    return std::string("");
+}
+
 void PulseNode::update(const pa_channel_map &channel_map,
                        const pa_cvolume &cvolume,
                        int32_t mute,
diff --git a/plugins/audio/pulse/pulse-node.h b/plugins/audio/pulse/pulse-node.h
index 664005c..06a76a7 100644
--- a/plugins/audio/pulse/pulse-node.h
+++ b/plugins/audio/pulse/pulse-node.h
@@ -96,7 +96,7 @@ public:
     uint32_t get_base_volume();
 
     // 获取属性
-    std::string get_property(const std::string &key) { return MapHelper::get_value(this->attrs_, key); };
+    std::string get_property(const std::string &key);
 
     sigc::signal<void, PulseNodeField> &signal_node_info_changed() { return this->node_info_changed_; };
 
-- 
2.27.0

