]> sigrok.org Git - libserialport.git/commit - windows.c
windows: wc_to_utf8(): Fix a WCHAR related issue causing crashes.
authorMartin Jackson <redacted>
Sat, 9 Sep 2017 22:37:48 +0000 (00:37 +0200)
committerUwe Hermann <redacted>
Sun, 30 Jun 2019 12:23:59 +0000 (14:23 +0200)
commit38b71192dd70336eba219994b0a4219a48e4cbe1
tree5126adda9e9205d32032f3b0e413dac834c79232
parenta84ffb537270666b652f70e4f836e88cd331d683
windows: wc_to_utf8(): Fix a WCHAR related issue causing crashes.

In wc_to_utf8() in windows.c, the zero terminator is written to an invalid
array index, which results in 2 bytes being zeroed in a random place in the
stack. This sometimes causes a crash when running sp_list_ports() (depending
on string length and compiler optimisation settings).

sizeof(wc_str) returns the size in bytes, so cannot be used directly as an
index into that array, it should be divided by sizeof(WCHAR). Otherwise the
zero terminator index is approximately twice what it should be.

This fixes bug #1031.
windows.c