[PATCH] loader: Negative loop bound

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

 



osinfo_loader_nodeset() can return -1 without set an error

Caught by: https://scan.coverity.com
---
 osinfo/osinfo_loader.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index aa5e48f..859328b 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -673,7 +673,7 @@ static void osinfo_loader_datamap(OsinfoLoader *loader,
     OsinfoDatamap *map = osinfo_loader_get_datamap(loader, id);
 
     nnodes = osinfo_loader_nodeset("./entry", ctxt, &nodes, err);
-    if (error_is_set(err))
+    if (nnodes < 0 || error_is_set(err))
         goto cleanup;
 
     for (i = 0 ; i < nnodes ; i++) {
@@ -911,7 +911,7 @@ static OsinfoMedia *osinfo_loader_media (OsinfoLoader *loader,
     }
 
     gint nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err);
-    if (error_is_set(err)) {
+    if (nnodes < 0 || error_is_set(err)) {
         g_object_unref(media);
         return NULL;
     }
@@ -1002,7 +1002,7 @@ static OsinfoTree *osinfo_loader_tree (OsinfoLoader *loader,
     osinfo_loader_entity(loader, OSINFO_ENTITY(tree), keys, ctxt, root, err);
 
     gint nnodes = osinfo_loader_nodeset("./treeinfo/*", ctxt, &nodes, err);
-    if (error_is_set(err)) {
+    if (nnodes < 0 || error_is_set(err)) {
         g_object_unref(G_OBJECT(tree));
         return NULL;
     }
@@ -1176,7 +1176,7 @@ static OsinfoDeviceDriver *osinfo_loader_driver(OsinfoLoader *loader,
     }
 
     gint nnodes = osinfo_loader_nodeset("./*", ctxt, &nodes, err);
-    if (error_is_set(err)) {
+    if (nnodes < 0 || error_is_set(err)) {
         g_object_unref(G_OBJECT(driver));
         return NULL;
     }
@@ -1284,7 +1284,7 @@ static void osinfo_loader_os(OsinfoLoader *loader,
     g_free(nodes);
 
     nnodes = osinfo_loader_nodeset("./variant", ctxt, &nodes, err);
-    if (error_is_set(err))
+    if (nnodes < 0 || error_is_set(err))
         goto cleanup;
 
     for (i = 0 ; i < nnodes ; i++) {
-- 
1.9.0

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




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

  Powered by Linux