svn commit: r1296875 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1296875 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

jleroux@apache.org
Author: jleroux
Date: Sun Mar  4 21:13:15 2012
New Revision: 1296875

URL: http://svn.apache.org/viewvc?rev=1296875&view=rev
Log:
A patch from Shi Jinghai "out of range index exception in ShoppingCart.getAdjustmentPromoIndex()" https://issues.apache.org/jira/browse/OFBIZ-4720

This has obviously never been tested. Incrementing a positive or 0 value with only a test on being > 0 can only end with and out of range index exception :/

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1296875&r1=1296874&r2=1296875&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Sun Mar  4 21:13:15 2012
@@ -2770,10 +2770,10 @@ public class ShoppingCart implements Ite
     public int getAdjustmentPromoIndex(String productPromoId) {
         int index = adjustments.size();
         while (index > 0) {
+            index--;
             if (adjustments.get(index).getString("productPromoId").equals(productPromoId)) {
                 return(index);
             }
-            index++;
         }
         return -1;
     }