Blame SOURCES/0028-Set-default-value-for-variable-to-prevent-crash-RhBu.patch

c115a0
From 553a2c585db50599d5028ea6bb6462281bb88d02 Mon Sep 17 00:00:00 2001
c115a0
From: Jaroslav Mracek <jmracek@redhat.com>
c115a0
Date: Mon, 11 Jul 2022 12:27:14 +0200
c115a0
Subject: [PATCH] Set default value for variable to prevent crash
c115a0
 (RhBug:2091636)
c115a0
c115a0
It ensure that read of file ended successfully.
c115a0
c115a0
https://bugzilla.redhat.com/show_bug.cgi?id=2091636
c115a0
---
c115a0
 dnf/conf/substitutions.py | 4 +++-
c115a0
 1 file changed, 3 insertions(+), 1 deletion(-)
c115a0
c115a0
diff --git a/dnf/conf/substitutions.py b/dnf/conf/substitutions.py
c115a0
index 703e4a4f..1281bdf0 100644
c115a0
--- a/dnf/conf/substitutions.py
c115a0
+++ b/dnf/conf/substitutions.py
c115a0
@@ -53,6 +53,7 @@ class Substitutions(dict):
c115a0
                 continue
c115a0
             for fsvar in fsvars:
c115a0
                 filepath = os.path.join(dir_fsvars, fsvar)
c115a0
+                val = None
c115a0
                 if os.path.isfile(filepath):
c115a0
                     try:
c115a0
                         with open(filepath) as fp:
c115a0
@@ -61,4 +62,5 @@ class Substitutions(dict):
c115a0
                             val = val[:-1]
c115a0
                     except (OSError, IOError):
c115a0
                         continue
c115a0
-                self[fsvar] = val
c115a0
+                if val is not None:
c115a0
+                    self[fsvar] = val
c115a0
-- 
c115a0
2.37.1
c115a0