The API for WideCharToMultiByte says that the src-string has only to be treated as NULL-terminated if srclen is -1.