Huw Davies (@huw) commented about dlls/winecoreaudio.drv/coreaudio.c:
for(i = 0; i < params->num; i++){
SIZE_T len = CFStringGetLength(info[i].name);
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;
Rather than decrement `name_len`, please use `name_len - 1` in both cases - it's easier to follow if as many things as possible are constant.