projects
/
platform
/
upstream
/
coreclr.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3d5b1d3
)
null terminate the converted LPStr at the right index (#17079)
author
Jeff Schwartz
<jeffschw@microsoft.com>
Wed, 21 Mar 2018 20:07:00 +0000
(13:07 -0700)
committer
Jan Kotas
<jkotas@microsoft.com>
Wed, 21 Mar 2018 20:07:00 +0000
(13:07 -0700)
src/vm/olevariant.cpp
patch
|
blob
|
history
diff --git
a/src/vm/olevariant.cpp
b/src/vm/olevariant.cpp
index 95c0b9b0cc861ae082b410acefbf972434d6f929..35936bbc5a0790249fe9a8d7e25e4a5bffb8141b 100644
(file)
--- 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;