Skip to content

Commit

Permalink
[release/7.0-rc2] Handle a null szPname field (#75716)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Sep 16, 2022
1 parent f0eb5ce commit fdca698
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public Native(WAVEOUTCAPS managed)
wMid = managed.wMid;
wPid = managed.wPid;
vDriverVersion = managed.vDriverVersion;
managed.szPname.CopyTo(MemoryMarshal.CreateSpan(ref szPname[0], szPnameLength));
Span<char> szPnameSpan = MemoryMarshal.CreateSpan(ref szPname[0], szPnameLength);
szPnameSpan.Clear();
managed.szPname?.CopyTo(szPnameSpan);
dwFormats = managed.dwFormats;
wChannels = managed.wChannels;
wReserved1 = managed.wReserved1;
Expand Down

0 comments on commit fdca698

Please sign in to comment.