commit: 7816796df99454603bd978dc1ea15d7a5b6abd9a
Author: Sven Eden <seden <AT> havi <DOT> de>
AuthorDate: Wed Feb 11 09:03:22 2015 +0000
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Wed Feb 11 09:03:22 2015 +0000
URL:
http://sources.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=7816796d
Portage.pm: Fixed a possible "Use of uninitialized value" if a read file is
empty. (Bug #539682)
---
Portage.pm | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/Portage.pm b/Portage.pm
index 534de52..d90be5e 100644
--- a/Portage.pm
+++ b/Portage.pm
@@ -418,7 +418,8 @@ sub _determine_profiles
@_profiles = -l $mp_path ? _norm_path('/etc', $mp) : $mp;
for (my $i = -1; $i >= -@_profiles; $i--) {
for(_noncomments("${_profiles[$i]}/parent")) {
- splice(@_profiles, $i, 0, _norm_path(${_profiles[$i]},
$_));
+ length($_)
+ and splice(@_profiles, $i, 0,
_norm_path(${_profiles[$i]}, $_));
}
}
return;
@@ -723,9 +724,10 @@ sub _noncomments {
local $/;
if(open my $file, '<', $fname) {
binmode( $file, ":encoding(UTF-8)" );
- @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, <$file>."\n";
- shift @result if @result>0 && $result[0] eq '';
+ my $content = <$file> || "";
close $file;
+ @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, "$content\n";
+ shift @result while ( (@result > 0) &&
!length($result[0]) );
}
}
@@ -766,7 +768,8 @@ sub _read_archs {
for my $dir(@_profiles) {
next unless (-r "$dir/arch.list");
for my $arch (_noncomments("$dir/arch.list")) {
- defined($_use_temp->{$arch})
+ length($arch)
+ and defined($_use_temp->{$arch})
and delete($_use_temp->{$arch});
}
}