On 2013-03-26 9:08 AM, Martin Storsjö wrote: > From: Reimar Döffinger <[email protected]> > > - Make MultiByteToWideChar fail when it encounters invalid encoding. > Without this, invalid characters might just be skipped > - When MultiByteToWideChar fails, assume the file name is in CP_ACP > and open it via normal open function, even when the file will be > written > - When malloc fails return error instead of crashing > --- > libavformat/os_support.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-)
[...] > /* convert UTF-8 to wide chars */ > - num_chars = MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, NULL, 0); > + num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, > filename_utf8, -1, NULL, 0); > if (num_chars <= 0) > - return -1; > + goto fallback; NIT: Less than 0 is never possible[1]. > filename_w = av_mallocz(sizeof(wchar_t) * num_chars); > + if (!filename_w) > + return -1; Real error code maybe? Rest OK. - Derek [1] http://msdn.microsoft.com/en-ca/library/windows/desktop/dd319072(v=vs.85).aspx _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
