MASON-INTEREST-L Archives

January 2013

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Wed, 2 Jan 2013 15:46:29 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (34 lines)
On Jan 2, 2013, at 3:18 PM, Kuu wrote:

> Focusing in the possible bug, in the SparseGrid2D class, in the function reduceObjectsAtLocations() (line 620), there is a call to the method getObjectsAtLocation() in the line 636, which may return a null value, the code is:
>  
> Bag temp = getObjectsAtLocation(xs[i],ys[i]);      //line 636 this can return 'null'
> int size = temp.numObjs;                    //line 637
>  
> And as you can see, if the value of "temp" is null, the line 637 will throw a null pointer exception as it's happening to me.

Hi Javier, I think you are correct.  The correct code should include a null check:

    // for each location...
    for(int i=0; i < len; i++)
        {
        Bag temp = getObjectsAtLocation(xs[i],ys[i]);
        if (temp != null)
            {
            final int size = temp.numObjs;
            final Object[] os = temp.objs;
            // for each object at that location...
            for(int j = 0; j < size; j++)
                {
                // add the result, the x, and the y
                result.add(os[j]);
                newXPos.add(xs[i]);
                newYPos.add(ys[i]);
                }
             }
        }

There are similar errors in SparseGrid3D and the two Continuous classes.

Sean

ATOM RSS1 RSS2