1 |
commit: 7816796df99454603bd978dc1ea15d7a5b6abd9a |
2 |
Author: Sven Eden <seden <AT> havi <DOT> de> |
3 |
AuthorDate: Wed Feb 11 09:03:22 2015 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Wed Feb 11 09:03:22 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=7816796d |
7 |
|
8 |
Portage.pm: Fixed a possible "Use of uninitialized value" if a read file is empty. (Bug #539682) |
9 |
|
10 |
--- |
11 |
Portage.pm | 11 +++++++---- |
12 |
1 file changed, 7 insertions(+), 4 deletions(-) |
13 |
|
14 |
diff --git a/Portage.pm b/Portage.pm |
15 |
index 534de52..d90be5e 100644 |
16 |
--- a/Portage.pm |
17 |
+++ b/Portage.pm |
18 |
@@ -418,7 +418,8 @@ sub _determine_profiles |
19 |
@_profiles = -l $mp_path ? _norm_path('/etc', $mp) : $mp; |
20 |
for (my $i = -1; $i >= -@_profiles; $i--) { |
21 |
for(_noncomments("${_profiles[$i]}/parent")) { |
22 |
- splice(@_profiles, $i, 0, _norm_path(${_profiles[$i]}, $_)); |
23 |
+ length($_) |
24 |
+ and splice(@_profiles, $i, 0, _norm_path(${_profiles[$i]}, $_)); |
25 |
} |
26 |
} |
27 |
return; |
28 |
@@ -723,9 +724,10 @@ sub _noncomments { |
29 |
local $/; |
30 |
if(open my $file, '<', $fname) { |
31 |
binmode( $file, ":encoding(UTF-8)" ); |
32 |
- @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, <$file>."\n"; |
33 |
- shift @result if @result>0 && $result[0] eq ''; |
34 |
+ my $content = <$file> || ""; |
35 |
close $file; |
36 |
+ @result = split /(?:[^\S\n]*(?:#.*)?\n)+/, "$content\n"; |
37 |
+ shift @result while ( (@result > 0) && !length($result[0]) ); |
38 |
} |
39 |
} |
40 |
|
41 |
@@ -766,7 +768,8 @@ sub _read_archs { |
42 |
for my $dir(@_profiles) { |
43 |
next unless (-r "$dir/arch.list"); |
44 |
for my $arch (_noncomments("$dir/arch.list")) { |
45 |
- defined($_use_temp->{$arch}) |
46 |
+ length($arch) |
47 |
+ and defined($_use_temp->{$arch}) |
48 |
and delete($_use_temp->{$arch}); |
49 |
} |
50 |
} |