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

[libvirt] [PATCH] Add missing strdup return value check



From: Roopa Prabhu <roprabhu cisco com>

Check strdup return value and fail if error

Signed-off-by: Roopa Prabhu <roprabhu cisco com>
---
 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;
      }
 


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