summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorJeff Schwartz <jeffschw@microsoft.com>2018-03-21 13:07:00 -0700
committerJan Kotas <jkotas@microsoft.com>2018-03-21 13:07:00 -0700
commite99c94d3108257c61d5690d15662c020a2b5ba07 (patch)
tree04814f6db12af87fa6345a733c0579cf00929768 /src/vm
parent3d5b1d3d28d3b0a73b41716998600d8675a1d9e0 (diff)
downloadcoreclr-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.cpp5
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;