Closed massimomorara closed 7 years ago
This is done. Thanks. I need to check if this appear elsewhere.
Good. There is just a misprint in parseDomain()
: "Intger" (two times) that should be "Integer".
Note that foo..bar should be foo..bar
The type attribute is required for all types of variables except for integer variables.
Sorry but I don't understand the part "should be foo..bar"
Sorry, one part of my answer was missing. I just wanted to say that if you want to declare a symbolic variable, it is required to have type="symbolic", as for example : foo Concerning foo..bar this seems incorrect to me because it is not possible to define intervals with symbols.
I did not explain well (my English is very poor; sorry).
I try with other word.
My intention, opening this issue was to show that, if you define a integer variable using garbage, there wasn't a valid check to detect that there is a correct number. Or better: there was the check in the function used to extract the number but the returned value was unused.
In other words: foo
and bar
wasn't intended as symbolic variable but only as sequences of letters where should be numbers.
Parsing the following xml
the (unacceptable, I hope) interval
foo..bar
is accepted as0..0
(but the exact values are undefined, according the C++ standard).The problem is in
XMLParser::parseDomain()
(XMLParser.cc) where is used the methodto()
ofUTF8String
to detect thefirst
and thelast
value of the intervalbut there isn't a check for the value returned by
to()
that say if there was an error in the detection.Same problem with the single value part of the function: the is no check for the value returned by
so is accepted a variable as
A possible solution for the problem is the following
but I suppose that the problem is in other method too (in the following
void XMLParser::parseListOfIntegerOrInterval()
, by example)En passant... in
parseDomain()
(as similarly in other methods/functions) you passtxt
asconst UTF8String
anddomain
as pointer toXDomainInteger
.I suggest to pass
txt
as a const reference (UTF8String const & txt
), to avoid an unuseful copy of the object, anddomain
as a reference toXDomainInteger
(XDomainInteger & domain
) to avoid the risk thatparseDomain()
is called with an unchecked null pointer.