On Monday 14 April 2008 05:18, [EMAIL PROTECTED] wrote: > Author: nextgens > Date: 2008-04-14 04:18:17 +0000 (Mon, 14 Apr 2008) > New Revision: 19299 > > Modified: > trunk/freenet/src/freenet/node/FailureTable.java > Log: > prevent a potential array out of bounds
Please revert. If offers.length == 0 then idx will == -1 and therefore we will
return and not get an error.
>
> Modified: trunk/freenet/src/freenet/node/FailureTable.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/FailureTable.java 2008-04-14 04:09:28 UTC
(rev 19298)
> +++ trunk/freenet/src/freenet/node/FailureTable.java 2008-04-14 04:18:17 UTC
(rev 19299)
> @@ -158,14 +158,16 @@
> if(offers[i] == offer) idx = i;
> }
> if(idx == -1) return;
> - BlockOffer[] newOffers = new
> BlockOffer[offers.length-1];
> - if(idx > 0)
> - System.arraycopy(offers, 0, newOffers,
> 0, idx);
> - if(idx < newOffers.length)
> - System.arraycopy(offers, idx+1,
> newOffers, idx, offers.length-idx-1);
> - offers = newOffers;
> + if(offers.length > 1) {
> + BlockOffer[] newOffers = new
> BlockOffer[offers.length-1];
> + if(idx > 0)
> + System.arraycopy(offers, 0,
> newOffers, 0, idx);
> + if(idx < newOffers.length)
> + System.arraycopy(offers, idx+1,
> newOffers, idx, offers.length-idx-1);
> + offers = newOffers;
> + }
> }
> - if(offers.length == 0) {
> + if(offers.length < 1) {
> synchronized(FailureTable.this) {
>
> blockOfferListByKey.removeKey(entry.key);
> }
>
> _______________________________________________
> cvs mailing list
> [EMAIL PROTECTED]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
pgpnJD2Fs0n5w.pgp
Description: PGP signature
_______________________________________________ Devl mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
