No need to change this commit, this is just for the record so I can search
the archives for GIGO someday.  This is certainly a friendly thing to do,
and proxy is so slow that you probably won't be able to measure the effect
of the extra if statement, but this would otherwise be an example of a
change that violates the GIGO principle (Garbage In, Garbage Out).

This method is often used in loops so normally I would just let it RTE
instead of adding an if statement.  Again, in FlexJS, I hope we can have
friendlier debug versions of things like this so you don't pay in
production.


On 5/10/13 8:45 PM, "jmcl...@apache.org" <jmcl...@apache.org> wrote:

> FLEX-24296 throw out of range error if passed negative index
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/7490dc68
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/7490dc68
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/7490dc68
> 
> Branch: refs/heads/develop
> Commit: 7490dc6895ad483e715556d0d2db4315a806d38b
> Parents: d79d9ba
> Author: Justin Mclean <jmcl...@apache.org>
> Authored: Sat May 11 13:09:01 2013 +1000
> Committer: Justin Mclean <jmcl...@apache.org>
> Committed: Sat May 11 13:09:01 2013 +1000
> 
> ----------------------------------------------------------------------
>  .../src/mx/collections/ListCollectionView.as       |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7490dc68/frameworks/proje
> cts/framework/src/mx/collections/ListCollectionView.as
> ----------------------------------------------------------------------
> diff --git 
> a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
> b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
> index 9c8ee8d..746a3e2 100644
> --- a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
> +++ b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as
> @@ -911,6 +911,14 @@ public class ListCollectionView extends Proxy
>          {
>              // If caller passed in a number such as 5.5, it will be floored.
>              var n:Number = parseInt(String(name));
> +   
> +   if (n < 0)
> +   {
> +    var message:String = resourceManager.getString(
> +     "collections", "outOfBounds", [ -1 ]);
> +    throw new RangeError(message);
> +   }
> +   
>              if (!isNaN(n))
>                  index = int(n);
>          }
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to