[Gambas-user] [CRASH REPORT] XmlElement.GetAttribute (gb.xml) segfault if the attribute is an empty string
Adrien Prokopowicz
adrien.prokopowicz at ...626...
Tue Sep 13 14:40:57 CEST 2016
Le Tue, 13 Sep 2016 14:00:44 +0200, Tobias Boege <taboege at ...626...> a
écrit:
> 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
>
Damn Tobias, you're fast ! I saw your message just when I commited my
fixes.
I think that overwrote it, but thanks still. :)
I took the opportunity to spread the fix to the .GetAttribute() method,
which works
the same way.
However, this raised a question to me : Shouldn't be GB.ReturnNewString()
return null
when either the length or the value is null, instead of just crashing ?
Regards,
--
Adrien Prokopowicz
More information about the User
mailing list