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 {
4949 SimpleString (const char *input_data)
5050 : SimpleString(input_data, strlen(input_data)) {}
5151
52+
5253 SimpleString (const char *input_data, std::size_t size)
5354 {
5455 createImpl (input_data, size);
@@ -132,6 +133,7 @@ class SimpleString {
132133 constexpr static std::size_t CAPACITY = 15 ; // sizeof(String) - 1);
133134 constexpr static std::size_t IS_LONG_BIT = 1 << 7 ;
134135 constexpr static std::size_t LONG_MASK = (~std::size_t (0 )) >> 1 ;
136+ constexpr static std::size_t MAX_SIZE = 100UL *1024UL *1024UL ;
135137
136138 union {
137139 String str;
@@ -146,6 +148,10 @@ class SimpleString {
146148
147149 void createImpl (const char *input_data, std::size_t size)
148150 {
151+ if (size > MAX_SIZE){
152+ throw std::invalid_argument (" size too large for a simple string" );
153+ }
154+
149155 if (size > CAPACITY) {
150156 _storage.str .size = size;
151157 _storage.soo .capacity_left = IS_LONG_BIT;
You can’t perform that action at this time.
0 commit comments