[tbb-commits] [rbm/master] Avoid modifying $input_files

boklm at torproject.org boklm at torproject.org
Thu Apr 27 10:44:17 UTC 2017


commit 106e9b05aeff6309e241a3c9bae1781e0d551e7a
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Thu Apr 27 12:30:25 2017 +0200

    Avoid modifying $input_files
    
    If an input_file contains a 'target' value we process it as a template
    and modify it. However we should not do that as a project (and its
    input files) can be used multiple times with different contexts in the
    same build. Instead we should make a copy of the $input_file before we
    modify it.
---
 lib/RBM.pm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/RBM.pm b/lib/RBM.pm
index 50332d7..6825050 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -751,7 +751,8 @@ sub input_files {
     my $src_dir = "$proj_dir/$project";
     my $old_cwd = getcwd;
     chdir $src_dir || exit_error "cannot chdir to $src_dir";
-    foreach my $input_file (@$input_files) {
+    foreach my $input_file_alias (@$input_files) {
+        my $input_file = $input_file_alias;
         if (!ref $input_file) {
             $input_file = project_config($project,
                 process_template_opt($project, $input_file, $options), $options);
@@ -765,10 +766,10 @@ sub input_files {
         if ($input_file->{enable} && !$t->('enable')) {
             next;
         }
-        if ($input_file->{target} && ! $input_file->{_target_processed}) {
+        if ($input_file->{target}) {
+            $input_file = { %$input_file };
             $input_file->{target} = process_template_opt($project,
                                         $input_file->{target}, $options);
-            $input_file->{_target_processed} = 1;
         }
         if ($action eq 'getfnames') {
             my $getfnames_name;



More information about the tbb-commits mailing list