dnf/backport-set-default-value-for-variable-to-prevent-crash.patch
chenhaxing 432b0f824d dnf:backport some patches
(cherry picked from commit 7c67dd07fb9d765156111461e728ff3f9bf3b84c)
2023-02-14 14:25:51 +08:00

38 lines
1.3 KiB
Diff

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