[Rt-commit] rt branch, 4.4/copy-lifecycle-before-modify, created. rt-4.4.3-19-gf4d28029f

Jim Brandt jbrandt at bestpractical.com
Tue Jul 24 17:19:18 EDT 2018


The branch, 4.4/copy-lifecycle-before-modify has been created
        at  f4d28029fdfd1148558ba944a3163caeadb58390 (commit)

- Log -----------------------------------------------------------------
commit f4d28029fdfd1148558ba944a3163caeadb58390
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Jul 5 14:24:34 2018 -0400

    Copy lifecycle array before iterating and possibly modifying
    
    Inside the loop we may modify @res and remove a value. In some
    versions of perl (at least 5.16), the inner @res and aliased $_
    values used in the grep can iterate over the undef'd values,
    resulting in warnings like:
    
        Use of uninitialized value in string eq
    
    Create a copy to avoid this.

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 36ab6f3db..0e2934658 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -524,8 +524,9 @@ sub Actions {
         @{ $self->{'data'}{'actions'} };
 
     # skip '* -> x' if there is '$from -> x'
+    my @temp = @res; # Create a copy for the inner grep since we modify in the loop
     foreach my $e ( grep $_->{'from'} eq '*', @res ) {
-        $e = undef if grep $_->{'from'} ne '*' && $_->{'to'} eq $e->{'to'}, @res;
+        $e = undef if grep $_->{'from'} ne '*' && $_->{'to'} eq $e->{'to'}, @temp;
     }
     return grep defined, @res;
 }

-----------------------------------------------------------------------


More information about the rt-commit mailing list