Fix fencepost error in orders import. Fixes #1177.

develop
Ben Lubar 2017-10-16 14:01:23 -05:00
parent 0ee421a9d4
commit cc595d7a4e
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24
1 changed files with 11 additions and 4 deletions

@ -146,15 +146,22 @@ static void json_array_to_bitfield(B & bits, Json::Value & arr)
return; return;
} }
for (Json::ArrayIndex i = arr.size() - 1; i != 0; i--) for (Json::ArrayIndex i = arr.size(); i != 0; i--)
{ {
if (!arr[i - 1].isString())
{
continue;
}
std::string str(arr[i - 1].asString());
int current; int current;
if (get_bitfield_field(&current, bits, arr[i].asString())) if (get_bitfield_field(&current, bits, str))
{ {
if (!current && set_bitfield_field(&bits, arr[i].asString(), 1)) if (!current && set_bitfield_field(&bits, str, 1))
{ {
Json::Value removed; Json::Value removed;
arr.removeIndex(i, &removed); arr.removeIndex(i - 1, &removed);
} }
} }
} }