From e063c8e0aa04f0b09962be8b6c586c1d021a929f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 19 Dec 2013 23:58:53 +0200 Subject: [PATCH] Fix logic problems when ignoring a statement in the middle of direct load Each recursive call to parse() was subtracting one from sub_remaining, causing it to get out of sync with the actual statement hierarchy. --- source/binaryparser.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/binaryparser.cpp b/source/binaryparser.cpp index 051133f..e2ced82 100644 --- a/source/binaryparser.cpp +++ b/source/binaryparser.cpp @@ -48,7 +48,10 @@ Statement BinaryParser::parse() { const StatementKey *key; if(cur_info) + { key = &cur_info->key; + cur_info = 0; + } else { int id = parse_int(); @@ -84,15 +87,16 @@ Statement BinaryParser::parse() } } - if(!sub_remaining.empty()) - --sub_remaining.back(); + unsigned upper_nsub = (sub_remaining.empty() ? 0 : sub_remaining.back()); unsigned nsub = parse_int(); for(unsigned j = 0; j0) + sub_remaining.back() = upper_nsub-1; + result.valid = true; - cur_info = 0; return result; } -- 2.43.0