Skip to content

Commit 058e81e

Browse files
committed
control depth of collectGroups so avoid overrunning data tokens after a nested group.
1 parent becc53d commit 058e81e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/GenerationUtil.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,21 @@ public static int collectGroups(final List<Token> tokens, final int index, final
5151
{
5252
int groupStart = -1;
5353
int groupEnd = -1;
54+
int depth = 0;
5455
for (int i = index, size = tokens.size(); i < size; i++)
5556
{
5657
final Token token = tokens.get(i);
57-
if (Signal.BEGIN_GROUP == token.signal() && -1 == groupStart)
58+
if (Signal.BEGIN_GROUP == token.signal())
5859
{
59-
groupStart = i;
60+
if (-1 == groupStart)
61+
{
62+
groupStart = i;
63+
}
64+
65+
depth++;
6066
}
6167

62-
if (Signal.END_GROUP == token.signal())
68+
if (Signal.END_GROUP == token.signal() && --depth >= 0)
6369
{
6470
groupEnd = i;
6571
}

sbe-tool/src/test/cpp/GroupWithDataTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "gtest/gtest.h"
1919
#include "group_with_data/TestMessage1.hpp"
2020
#include "group_with_data/TestMessage2.hpp"
21+
#include "group_with_data/TestMessage3.hpp"
2122
#include "group_with_data/TestMessage4.hpp"
2223

2324
using namespace std;
@@ -128,6 +129,7 @@ class GroupWithDataTest : public testing::Test
128129

129130
TestMessage1 msg1_;
130131
TestMessage2 msg2_;
132+
TestMessage3 msg3_;
131133
TestMessage4 msg4_;
132134
};
133135

0 commit comments

Comments
 (0)