XmlRpcStruct | Possible duplicate key in private ArrayList
Opened this issue · 0 comments
titobrasolin commented
In my opinion there is a problem in this override: https://github.com/snielsson/XmlRpcLight/blob/master/XmlRpcLight/DataTypes/XmlRpcStruct.cs#L21
Setting an item always adds a new _key e.g.
var x = new XmlRpcStruct ();
x ["title"] = "Hi!";
x ["title"] = "Hi again!";
x ["title"] = "Hi (third time)!";
You will end up with a single "title" in the base class but three items in the private _keys.
This can possibly lead to serialization problems.
Possible solution: check if the key already exists e.g. after line 31
var indexOfKey = _keys.IndexOf (key);
if (indexOfKey < 0) {
_keys.Add (key);
_values.Add (value);
} else {
_values [indexOfKey] = value;
}