diff options
author | Jeff Schwartz <jeffschw@microsoft.com> | 2018-03-21 13:07:00 -0700 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2018-03-21 13:07:00 -0700 |
commit | e99c94d3108257c61d5690d15662c020a2b5ba07 (patch) | |
tree | 04814f6db12af87fa6345a733c0579cf00929768 /src/vm | |
parent | 3d5b1d3d28d3b0a73b41716998600d8675a1d9e0 (diff) | |
download | coreclr-e99c94d3108257c61d5690d15662c020a2b5ba07.tar.gz coreclr-e99c94d3108257c61d5690d15662c020a2b5ba07.tar.bz2 coreclr-e99c94d3108257c61d5690d15662c020a2b5ba07.zip |
null terminate the converted LPStr at the right index (#17079)
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/olevariant.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vm/olevariant.cpp b/src/vm/olevariant.cpp index 95c0b9b0cc..35936bbc5a 100644 --- a/src/vm/olevariant.cpp +++ b/src/vm/olevariant.cpp @@ -2310,8 +2310,9 @@ void OleVariant::MarshalLPSTRRArrayComToOle(BASEARRAYREF *pComArray, void *oleAr ThrowOutOfMemory(); // Convert the unicode string to an ansi string. - InternalWideToAnsi(stringRef->GetBuffer(), Length, lpstr, allocLength, fBestFitMapping, fThrowOnUnmappableChar); - lpstr[Length] = 0; + int bytesWritten = InternalWideToAnsi(stringRef->GetBuffer(), Length, lpstr, allocLength, fBestFitMapping, fThrowOnUnmappableChar); + _ASSERTE(bytesWritten >= 0 && bytesWritten < allocLength); + lpstr[bytesWritten] = 0; } *pOle++ = lpstr; |