From: Changgyu Choi Date: Mon, 29 Jan 2024 09:37:37 +0000 (+0900) Subject: Fix critical section range X-Git-Tag: accepted/tizen/unified/20240131.175428~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f718d1439f9ea6bb179a9a0b696c14817d53290;p=platform%2Fcore%2Fappfw%2Frpc-port.git Fix critical section range lock should be get before checking whether listener_ is nullptr or not. Change-Id: Ied8d03d9bc772542837d7f8b5f2eb1ad8a61c5e9 Signed-off-by: Changgyu Choi --- diff --git a/src/stub-internal.cc b/src/stub-internal.cc index 0abc27d..d968ff9 100644 --- a/src/stub-internal.cc +++ b/src/stub-internal.cc @@ -111,12 +111,12 @@ int Stub::Listen(IEventListener* ev, int fd) { if (ev == nullptr) return RPC_PORT_ERROR_INVALID_PARAMETER; + std::lock_guard lock(GetMutex()); if (listener_ != nullptr) { _E("Already listening!"); // LCOV_EXCL_LINE return RPC_PORT_ERROR_INVALID_PARAMETER; // LCOV_EXCL_LINE } - std::lock_guard lock(GetMutex()); listener_ = ev; server_.reset(new Server(fd, this)); return server_->Listen();