grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Grammatica-users] Bug: ParseException.Details will crash when error doe


From: William Lahti
Subject: [Grammatica-users] Bug: ParseException.Details will crash when error does not provide a Details list
Date: Tue, 24 Mar 2009 14:25:03 -0400

If you receive a ParseException and try to inspect it's Details property, it may crash if the exception has a null 'details' field, as get_Details tries to make a copy of the 'details' field without checking if it's null. 

Here's the exception I received:

System.ArgumentNullException: Collection cannot be null.
Parameter name: c
   at System.Collections.ArrayList..ctor(ICollection c)
   at PerCederberg.Grammatica.Runtime.ParseException.get_Details()
   ...

Here's the offending property:

       public ArrayList Details {
            get {
                return new ArrayList(details);
            }
        }

It's found at line 208 in src/csharp/PerCederberg.Grammatica.Runtime/ParseException.cs

The fix is easy:

       public ArrayList Details {
            get {
                if (details == null)
                       return new ArrayList (); // or just null, but an empty list makes more sense imho
                return new ArrayList(details);
            }
        }

Sorry I couldn't provide a patch, but I don't have a proper diff tool on this Windows box and it's a really minor change (though hard to get around without recompiling Grammatica).
--
rezonant

long name: William Lahti
handle :: rezonant
freenode :: xfury
blog :: http://xfurious.blogspot.com/
site :: http://komodocorp.com/~wilahti

reply via email to

[Prev in Thread] Current Thread [Next in Thread]