[PATCH] Add missing strdup return value check

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

 



From: Roopa Prabhu <roprabhu@xxxxxxxxx>

Check strdup return value and fail if error

Signed-off-by: Roopa Prabhu <roprabhu@xxxxxxxxx>
---
 src/util/pci.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/src/util/pci.c b/src/util/pci.c
index 2bbb90c..df4e6c8 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -2018,7 +2018,13 @@ pciDeviceNetName(char *device_link_sysfs_path, char **netname)
 
             /* Assume a single directory entry */
             *netname = strdup(entry->d_name);
-            ret = 0;
+            if (!*netname) {
+                virReportOOMError();
+                ret = -1;
+            }
+            else {
+                ret = 0;
+            }
             break;
      }
 

--
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]