From cc595d7a4ed3d72f654e4474fd62563f9930983e Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 16 Oct 2017 14:01:23 -0500 Subject: [PATCH] Fix fencepost error in orders import. Fixes #1177. --- plugins/orders.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/orders.cpp b/plugins/orders.cpp index 53c1844ac..4a2e3b0c0 100644 --- a/plugins/orders.cpp +++ b/plugins/orders.cpp @@ -146,15 +146,22 @@ static void json_array_to_bitfield(B & bits, Json::Value & arr) 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; - if (get_bitfield_field(¤t, bits, arr[i].asString())) + if (get_bitfield_field(¤t, bits, str)) { - if (!current && set_bitfield_field(&bits, arr[i].asString(), 1)) + if (!current && set_bitfield_field(&bits, str, 1)) { Json::Value removed; - arr.removeIndex(i, &removed); + arr.removeIndex(i - 1, &removed); } } }