[open-ils-commits] [GIT] Evergreen ILS branch master updated. d8eacd2fd21ed5b6670333ad3a2d4c685634680f

Evergreen Git git at git.evergreen-ils.org
Wed Aug 9 15:48:24 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, master has been updated
       via  d8eacd2fd21ed5b6670333ad3a2d4c685634680f (commit)
      from  fc2dcdadb96da9d5b051703e9b65290025bac6f7 (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 d8eacd2fd21ed5b6670333ad3a2d4c685634680f
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