On Wed, 27 Mar 2013, Derek Buitenhuis wrote:
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].
Noted. I don't mind keeping it like this anyway, though.
filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
+ if (!filename_w)
+ return -1;
Real error code maybe?
No, this is used as a replacement for open(), which is supposed to return
exactly -1 on errors, nothing else (negative file descriptors are valid).
It could set errno to ENOMEM, though, amended with that.
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel