Skip to content

Commit

Permalink
null terminate the converted LPStr at the right index (dotnet/coreclr…
Browse files Browse the repository at this point in the history
…#17079)

Commit migrated from dotnet/coreclr@e99c94d
  • Loading branch information
jeffschwMSFT authored and jkotas committed Mar 21, 2018
1 parent d4500ee commit 5929b34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/coreclr/src/vm/olevariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5929b34

Please sign in to comment.