Skip to content

Commit fdca698

Browse files
[release/7.0-rc2] Handle a null szPname field (#75716)
* Handle a null szPname field * Always clear the span to ensure we have a null terminator in case the string is short * Use null conditional access * Add call to test to test scenario * Update src/libraries/System.Speech/tests/SynthesizeRecognizeTests.cs Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com> Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
1 parent f0eb5ce commit fdca698

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/libraries/Common/src/Interop/Windows/WinMm/Interop.waveOutGetDevCaps.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public Native(WAVEOUTCAPS managed)
5050
wMid = managed.wMid;
5151
wPid = managed.wPid;
5252
vDriverVersion = managed.vDriverVersion;
53-
managed.szPname.CopyTo(MemoryMarshal.CreateSpan(ref szPname[0], szPnameLength));
53+
Span<char> szPnameSpan = MemoryMarshal.CreateSpan(ref szPname[0], szPnameLength);
54+
szPnameSpan.Clear();
55+
managed.szPname?.CopyTo(szPnameSpan);
5456
dwFormats = managed.dwFormats;
5557
wChannels = managed.wChannels;
5658
wReserved1 = managed.wReserved1;

0 commit comments

Comments
 (0)