[Gambas-user] [CRASH REPORT] XmlElement.GetAttribute (gb.xml) segfault if the attribute is an empty string
Tobias Boege
taboege at ...626...
Tue Sep 13 14:00:44 CEST 2016
On Tue, 13 Sep 2016, adamnt42 at ...626... wrote:
> Hello,
>
> Damned, my program crashed Gambas that way :
>
> The segfault occurs when I attempt to get the value of the argname attribute thus:
> hAD = New CArgDef
> With hAD
> .ShortName = hArg.Attributes["shortname"]
> .LongName = hArg.Attributes["longname"]
> .ArgName = hArg.Attributes["argname"]
> ...
>
> This happens if an XMLElement has an attribute whose value is an empty string, for example :
>
> <ArgDef desc="blah blah" longname="blah" argname="" />
>
> The argname attribute won't parse and the segfault occurs.
>
> I don't know whether such empty string attributes are "legal" in XML though.
>
They say here [1] that it is valid in the way you wrote it. In revision #7911
it doesn't crash anymore and returns an empty string. The fix consisted of
adding the magical quartet of the C programming language: `?:""'.
Regards,
Tobi
[1] http://stackoverflow.com/questions/6926442/is-an-xml-attribute-without-a-value-valid
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list