Skip to content

Commit

Permalink
Set default value for variable to prevent crash (RhBug:2091636)
Browse files Browse the repository at this point in the history
It ensure that read of file ended successfully.

https://bugzilla.redhat.com/show_bug.cgi?id=2091636
  • Loading branch information
j-mracek authored and m-blaha committed Jul 12, 2022
1 parent 12b5128 commit f8fed33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dnf/conf/substitutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def update_from_etc(self, installroot, varsdir=("/etc/yum/vars/", "/etc/dnf/vars
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:
Expand All @@ -61,4 +62,5 @@ def update_from_etc(self, installroot, varsdir=("/etc/yum/vars/", "/etc/dnf/vars
val = val[:-1]
except (OSError, IOError):
continue
self[fsvar] = val
if val is not None:
self[fsvar] = val

0 comments on commit f8fed33

Please sign in to comment.