Hi Irwin,
One security concern is that we allocate `moreSizes` on the stack, with size is proportional to `segmentCount`. If we were to accept any `uint32_t` value for `segmentCount`, then a malicious sender could trivially blow through the receiver's stack.
Segments get allocated as needed when you build a message. If you are using `MallocMessageBuilder` and setting `allocationStrategy` to `SUGGESTED_ALLOCATION_STRATEGY`, i.e. `GROW_HEURISTICALLY`, then the segment size grows exponentially, and you ought to run out of memory long before you use 512 segments.
Perhaps you are accidentally using the `FIXED_SIZE` allocation strategy?
Or perhaps you are trying to read a packed message and you forgot to use `PackedInputStream`?
- David