Huw Davies (@huw) commented about dlls/winecoreaudio.drv/coreaudio.c:
- needed += (len + 1) * sizeof(WCHAR); + SIZE_T name_len = CFStringGetLength(info[i].name) + 1; + const SIZE_T len = MAX_DEV_NAME_LEN + 1; + needed += name_len * sizeof(WCHAR) + ((len + 1) & ~1);
if(needed <= params->size){ endpoint->name = offset; ptr = (UniChar *)((char *)params->endpoints + offset); - CFStringGetCharacters(info[i].name, CFRangeMake(0, len), ptr); - ptr[len] = 0; - endpoint->id = info[i].id; + offset += name_len * sizeof(WCHAR); + CFStringGetCharacters(info[i].name, CFRangeMake(0, --name_len), ptr); + ptr[name_len] = 0; + endpoint->device = offset; + sprintf((char *)params->endpoints + offset, "%u", info[i].id); This is producing a warning for me:
gcc -m32 -c -o dlls/winecoreaudio.drv/coreaudio.o dlls/winecoreaudio.drv/coreaudio.c -Idlls/winecoreaudio.drv -Iinclude -D__WINESRC__ \
-D_UCRT -DWINE_UNIX_LIB -Wall -pipe -fno-stack-protector -fno-strict-aliasing \
-Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self -Wno-pragma-pack \
-Wstrict-prototypes -Wtype-limits -Wvla -Wwrite-strings -Wpointer-arith -gdwarf-4 \
-fno-omit-frame-pointer -fPIC -fasynchronous-unwind-tables -O2 -g -Wno-deprecated-declarations -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
dlls/winecoreaudio.drv/coreaudio.c:280:63: warning: values of type 'AudioDeviceID' should not be used as format arguments; add an explicit cast to 'unsigned int' instead [-Wformat]
sprintf((char *)params->endpoints + offset, "%u", info[i].id);
~~ ^~~~~~~~~~
%u (unsigned int)
1 warning generated.
You'll need to cast `info[i].id` to an `unsigned int`. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/813#note_8489