Skip to content

Conversation

Kein
Copy link

@Kein Kein commented Apr 13, 2021

StrToPtr() had at least 4 extra allocations of byte[] and char[] arrays that will make Unity's GC and frametime stability sad, taking into account you can updated 5 times per 20 seconds, which is few frames apart.
Also, there was 0 reason to have that marshaling invoke overhead where it zeroes byte by byte in a loop. There is no point, we already overwrite whole memory via .Copy() and we only allocate as much as needed for the string bytes, no extra. No security concerns here.

The only question that eludes me is the limitation of 128 bytes. It was not enforced on managed side in old code, and I could not find anything in native library. So I assume it is enforced on RPC server side then? Either way since limit is 128 bytes aka 128 ASCII characters at min, it makes sense to limit allocated data to 128 chars max to avoid sending perhaps megabytes of mistakenly generated by user string (I assume it will throw in pipe/socket).

Kein added 2 commits April 13, 2021 03:31
StrToPtr() had at least 4 extra allocations of byte[] and char[] arrays that will make Unity's GC and frametime stability sad, taking into account you can updated 5 times per 20 seconds, which is few frames apart.
Also, there was 0 reason to have that marshaling invoke overhead where it zeroes byte by byte in a loop. There is no point, we already overwrite whole memory via .Copy() and we only allocate as much as needed, no extra. No security concerns here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant