summaryrefslogtreecommitdiff
path: root/0114-bugfix-for-null-pointer-reference.patch
blob: a39467eb1df1495943175d0eb94c1a13c5d5e93f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 701180b53d1c52376f753b94c5cf09987ae789b3 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 18 Jun 2024 16:02:25 +0800
Subject: [PATCH 114/121] bugfix for null pointer reference

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/daemon/entry/connect/grpc/grpc_service.cc | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/daemon/entry/connect/grpc/grpc_service.cc b/src/daemon/entry/connect/grpc/grpc_service.cc
index 1d8de922..300af082 100644
--- a/src/daemon/entry/connect/grpc/grpc_service.cc
+++ b/src/daemon/entry/connect/grpc/grpc_service.cc
@@ -100,7 +100,9 @@ public:
     {
         // Wait for the server to shutdown. Note that some other thread must be
         // responsible for shutting down the server for this call to ever return.
-        m_server->Wait();
+        if (m_server != nullptr) {
+            m_server->Wait();
+        }
 
         // Wait for stream server to shutdown
         m_criService.Wait();
@@ -109,7 +111,9 @@ public:
     void Shutdown(void)
     {
         // call CRI to shutdown stream server, shutdown cri first to notify events thread to exit
-        m_criService.Shutdown();
+        if (m_server != nullptr) {
+            m_server->Shutdown();
+        }
 
         m_server->Shutdown();
 
@@ -242,10 +246,16 @@ int grpc_server_init(const struct service_arguments *args)
 
 void grpc_server_wait(void)
 {
+    if (g_grpcserver == nullptr) {
+        return;
+    }
     g_grpcserver->Wait();
 }
 
 void grpc_server_shutdown(void)
 {
+    if (g_grpcserver == nullptr) {
+        return;
+    }
     g_grpcserver->Shutdown();
 }
-- 
2.25.1