Fix crash issues of servers 94/315794/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 8 Aug 2024 00:06:18 +0000 (09:06 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 8 Aug 2024 00:08:53 +0000 (09:08 +0900)
While calling RemoveAcceptedPorts(), the server has crashed.
Because the instance argument is deleted at the for loop.
This patch changes the parameter type to std::string.

Change-Id: Ib7754d128df647b75643baf34d4eca3e62264fd1
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/rpc-port/stub-internal.cc
src/rpc-port/stub-internal.hh

index 87dc01199d20edf1307ed250aee65ee8deed88f3..d0e89d4f1479c7ac96dd3574386dff16fd873717 100644 (file)
@@ -135,7 +135,7 @@ const std::string& Stub::GetPortName() const {
   return port_name_;
 }
 
-void Stub::RemoveAcceptedPorts(const std::string& instance) {
+void Stub::RemoveAcceptedPorts(std::string instance) {
   std::lock_guard<std::recursive_mutex> lock(GetMutex());
   auto iter = ports_.begin();
   while (iter != ports_.end()) {
index f4818a2e90fb497046989ca545b16272d06a6f00..af15f68916efd54f6845974a3a8625fb26ba9465 100644 (file)
@@ -67,7 +67,7 @@ class Stub : public Server::IEvent, public AcceptedPort::IEvent {
  private:
   void AddAcceptedPort(const std::string& sender_appid,
       const std::string& instance, const std::string& port_type, int fd);
-  void RemoveAcceptedPorts(const std::string& instance);
+  void RemoveAcceptedPorts(std::string instance);
   std::recursive_mutex& GetMutex() const;
   int GetFdFromSystemd();
   int CreateServerSocket();