The native side of UT sometimes relies on the function
- Code: Select all
This is intended to interface a static string stack for temporary strings to avoid allocating/deallocating strings heavily due to the cost of malloc/dealloc.
It's very useful in that it saves a lot of processor time. The downside is that the blocksize is limited. Thus each string is limited to 1024 (1023 + nullterminator). In most cases it doesn't hurt to use more than 1023 in terms of risking
heap corruption because, if I recall, the stack is , so there are 512 x 1024 * sizeof(wchar_t) (which is 2 on MSVC). So unless you're on the last row in the stack, it wont go out of bounds completely. Of course, when the function is called next time it will overwrite anything beyond 1024 and destroy the null-terminator, thus causing havoc in other ways.
Conclusion? Don't ever use strings larger than 1023, Ever!
A string that large is very rare, and would most often never be seen other than during testing. It also takes forever to process for obvious reasons.
You can clamp the text using Str = Left(Str, 1023);
It may or may not help, depends on GetPropertyText and how it handles the result.
The string itself isn't limited, but the static string stack is, thus any function that uses it together with a string larger than 1023 will cause corruption.
So don't use GetPropertyText here, use the member access operator and then clamp the message using Left().
P.S That special event should be thrown away and tucked under something that will never see daylight again.