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

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