[open-ils-commits] [GIT] Evergreen ILS branch rel_2_12 updated. 86efb7a6f26d877ed8a82592935f2fffb4d8d5ca

Evergreen Git git at git.evergreen-ils.org
Wed Aug 9 15:49:32 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_12 has been updated
       via  86efb7a6f26d877ed8a82592935f2fffb4d8d5ca (commit)
      from  f2538c6bd0dd14579a985d20025c81c2120c8f59 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 86efb7a6f26d877ed8a82592935f2fffb4d8d5ca
Author: Jeff Davis <jdavis at sitka.bclibraries.ca>
Date:   Wed May 17 14:16:26 2017 -0700

    LP#1691563: Prevent "Use of freed value in iteration" error during adjust to zero
    
    Signed-off-by: Jeff Davis <jdavis at sitka.bclibraries.ca>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
index 1675712..b22fee4 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CircCommon.pm
@@ -804,7 +804,11 @@ sub bill_payment_map_for_xact {
     }
 
     # Try to map payments to bills by amounts starting with the
-    # largest payments:
+    # largest payments.
+    # To avoid modifying the array we're iterating over (which can result in a
+    # "Use of freed value in iteration" error), we create a copy of the
+    # payments array and remove handled payments from that instead.
+    my @handled_payments = @$payments;
     foreach my $payment (sort {$b->amount() <=> $a->amount()} @$payments) {
         my @bills2pay = grep {$_->{bill}->amount() == $payment->amount()} @entries;
         if (@bills2pay) {
@@ -812,10 +816,13 @@ sub bill_payment_map_for_xact {
             $entry->{bill}->amount(0);
             push @{$entry->{payments}}, $payment;
             # Remove the payment from the master list.
-            my @p = grep {$_->id() != $payment->id()} @$payments;
-            $payments = \@p;
+            my @p = grep {$_->id() != $payment->id()} @handled_payments;
+            @handled_payments = @p;
         }
     }
+    # Now, update our list of payments so that it only includes unhandled
+    # (unmapped) payments.
+    $payments = \@handled_payments;
 
     # Map remaining bills to payments in whatever order.
     foreach  my $entry (grep {$_->{bill}->amount() > 0} @entries) {

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

Summary of changes:
 .../lib/OpenILS/Application/Circ/CircCommon.pm     |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list