Le Tue, 13 Sep 2016 14:00:44 +0200, Tobias Boege <tabo...@gmail.com> a écrit:
> On Tue, 13 Sep 2016, adamn...@gmail.com 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 ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user