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

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