From 1f718d1439f9ea6bb179a9a0b696c14817d53290 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 29 Jan 2024 18:37:37 +0900 Subject: [PATCH] Fix critical section range lock should be get before checking whether listener_ is nullptr or not. Change-Id: Ied8d03d9bc772542837d7f8b5f2eb1ad8a61c5e9 Signed-off-by: Changgyu Choi --- src/stub-internal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); -- 2.7.4