[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 7/9] Avoid referencing NULL pointer when copying stream error



* src/rpc/virnetclientstream.c: Avoid referencing NULL
---
 src/rpc/virnetclientstream.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 44c9acf..99c7b41 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -217,13 +217,24 @@ int virNetClientStreamSetError(virNetClientStreamPtr st,
     } else {
         st->err.code = err.code;
     }
-    st->err.message = *err.message;
-    *err.message = NULL;
+    if (err.message) {
+        st->err.message = *err.message;
+        *err.message = NULL;
+    }
     st->err.domain = err.domain;
     st->err.level = err.level;
-    st->err.str1 = *err.str1;
-    st->err.str2 = *err.str2;
-    st->err.str3 = *err.str3;
+    if (err.str1) {
+        st->err.str1 = *err.str1;
+        *err.str1 = NULL;
+    }
+    if (err.str2) {
+        st->err.str2 = *err.str2;
+        *err.str2 = NULL;
+    }
+    if (err.str3) {
+        st->err.str3 = *err.str3;
+        *err.str3 = NULL;
+    }
     st->err.int1 = err.int1;
     st->err.int2 = err.int2;
 
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]