File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
include/behaviortree_cpp/utils Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class SimpleString {
49
49
SimpleString (const char *input_data)
50
50
: SimpleString(input_data, strlen(input_data)) {}
51
51
52
+
52
53
SimpleString (const char *input_data, std::size_t size)
53
54
{
54
55
createImpl (input_data, size);
@@ -132,6 +133,7 @@ class SimpleString {
132
133
constexpr static std::size_t CAPACITY = 15 ; // sizeof(String) - 1);
133
134
constexpr static std::size_t IS_LONG_BIT = 1 << 7 ;
134
135
constexpr static std::size_t LONG_MASK = (~std::size_t (0 )) >> 1 ;
136
+ constexpr static std::size_t MAX_SIZE = 100UL *1024UL *1024UL ;
135
137
136
138
union {
137
139
String str;
@@ -146,6 +148,10 @@ class SimpleString {
146
148
147
149
void createImpl (const char *input_data, std::size_t size)
148
150
{
151
+ if (size > MAX_SIZE){
152
+ throw std::invalid_argument (" size too large for a simple string" );
153
+ }
154
+
149
155
if (size > CAPACITY) {
150
156
_storage.str .size = size;
151
157
_storage.soo .capacity_left = IS_LONG_BIT;
You can’t perform that action at this time.
0 commit comments