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

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