Blame SOURCES/0002-rhbz-Be-a-little-bit-more-defensive-when-working-wit.patch

83467f
From 50fdc7f23f35744ffff1763fe2d804b18c1c5340 Mon Sep 17 00:00:00 2001
83467f
From: Michal Srb <michal@redhat.com>
83467f
Date: Tue, 7 Sep 2021 14:40:21 +0200
83467f
Subject: [PATCH] [rhbz] Be a little bit more defensive when working with
83467f
 subcomponents
83467f
83467f
Components in RHEL can have "subcomponents" in Bugzilla. Some of them
83467f
have, some of them don't. Better be careful.
83467f
83467f
See: rhbz#1998435
83467f
83467f
Signed-off-by: Michal Srb <michal@redhat.com>
83467f
---
83467f
 src/plugins/rhbz.c | 18 +++++++++++-------
83467f
 1 file changed, 11 insertions(+), 7 deletions(-)
83467f
83467f
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
83467f
index c2855a70..0dae1e93 100644
83467f
--- a/src/plugins/rhbz.c
83467f
+++ b/src/plugins/rhbz.c
83467f
@@ -1036,13 +1036,17 @@ char *rhbz_get_default_sub_component(const char *component, xmlrpc_value *sub_co
83467f
     }
83467f
     else
83467f
     {
83467f
-        xmlrpc_array_read_item(&env, sub_components, sc_array_size - 1, &sc_struct);
83467f
-        xmlrpc_struct_find_value(&env, sc_struct, "name", &sc_name);
83467f
-        xmlrpc_read_string(&env, sc_name, &sc_str_name);
83467f
-        if (sc_struct)
83467f
-            xmlrpc_DECREF(sc_struct);
83467f
-        if (sc_name)
83467f
-            xmlrpc_DECREF(sc_name);
83467f
+        if (sc_array_size) {
83467f
+            xmlrpc_array_read_item(&env, sub_components, sc_array_size - 1, &sc_struct);
83467f
+            if (xmlrpc_struct_has_key(&env, sc_struct, "name")) {
83467f
+                xmlrpc_struct_find_value(&env, sc_struct, "name", &sc_name);
83467f
+                xmlrpc_read_string(&env, sc_name, &sc_str_name);
83467f
+            }
83467f
+            if (sc_struct)
83467f
+                xmlrpc_DECREF(sc_struct);
83467f
+            if (sc_name)
83467f
+                xmlrpc_DECREF(sc_name);
83467f
+        }
83467f
     }
83467f
 
83467f
     return (char *)sc_str_name;
83467f
-- 
83467f
2.31.1
83467f