Each recursive call to parse() was subtracting one from sub_remaining,
causing it to get out of sync with the actual statement hierarchy.
{
const StatementKey *key;
if(cur_info)
{
const StatementKey *key;
if(cur_info)
else
{
int id = parse_int();
else
{
int id = parse_int();
- 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; j<nsub; ++j)
result.sub.push_back(parse());
unsigned nsub = parse_int();
for(unsigned j = 0; j<nsub; ++j)
result.sub.push_back(parse());
+ if(upper_nsub>0)
+ sub_remaining.back() = upper_nsub-1;
+