Make sure we consider buffer length when marshalling back Unicode ByValTStr fields...
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Mon, 28 Jun 2021 19:41:39 +0000 (12:41 -0700)
committerGitHub <noreply@github.com>
Mon, 28 Jun 2021 19:41:39 +0000 (12:41 -0700)
commit317783916d5695d86b087b45220a28c5d8db9fc6
treedc3c6079c48c75db4735c6a95c52a5bf1a26476d
parent909b1b29806de8adcd67b115c219b14acb3a61e3
Make sure we consider buffer length when marshalling back Unicode ByValTStr fields (#54695)

* Use string constructor that takes length instead of the one that searches for a null terminator.

Fixes #54662

* Marshal back buffer size or string to first null terminator, whichever is shorter

* Add tests.

* Add unicode test.

* Use the same implementation style for the wstr case case as the cstr case

* Fix accidental deletion from test.
src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs
src/coreclr/vm/corelib.h
src/coreclr/vm/ilmarshalers.cpp
src/tests/Interop/StringMarshalling/LPTSTR/LPTSTRTest.cs
src/tests/Interop/StringMarshalling/LPTSTR/LPTStrTestNative.cpp
src/tests/Interop/StringMarshalling/LPTSTR/LPTStrTestNative.cs