I just want to append on Remy's answer (as I don't have enough reputation to add a comment):
Passing pointer to the result of TEncoding.Default.GetBytes
into C is highly dangerous and buggy.
The result bytes are not zero terminated.
Possible fix is zero terminating the buffer yourself, such as:
SetLength(buffer, Length(buffer) + 1);
buffer[High(buffer)] := 0;