Merge pull request #1178 from BenLubar/orders-fencepost

Fix fencepost error in orders import.
develop
Lethosor 2017-11-23 11:55:47 -05:00 committed by GitHub
commit 6f44535d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
} }
} }
} }