[PATCH] util/vshstring: fix the vir_strdup when src is NULL.

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

 



When src is NULL, vir_strdup will return 0 directly.
This patch will set dest to NULL before vir_strdup return.

Signed-off-by: yangdongsheng <yangds.fnst@xxxxxxxxxxxxxx>
---
 src/util/virstring.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virstring.c b/src/util/virstring.c
index b244e6c..25b5d81 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -540,8 +540,10 @@ virStrdup(char **dest,
           const char *funcname,
           size_t linenr)
 {
-    if (!src)
+    if (!src) {
+        *dest = NULL;
         return 0;
+    }
     if (!(*dest = strdup(src))) {
         if (report)
             virReportOOMErrorFull(domcode, filename, funcname, linenr);
-- 
1.7.10.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]