aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2023-04-12 22:53:33 -0300
committerJames Almer <jamrial@gmail.com>2023-04-14 10:04:47 -0300
commit92885f26817b6b2515ac9fd5410c9e8be64bd0c0 (patch)
tree389ced5fd95951cfc548c7dbf804389410d251e7 /libavutil
parent19c2dc677f81c940aebe63ed09dacf5c725f0b35 (diff)
downloadffmpeg-92885f26817b6b2515ac9fd5410c9e8be64bd0c0.tar.gz
avutil/wchar_filename: propagate MultiByteToWideChar() and WideCharToMultiByte() failures
Don't return success if the string could not be converted. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/wchar_filename.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavutil/wchar_filename.h b/libavutil/wchar_filename.h
index 9a04a069f1..fbc0a55146 100644
--- a/libavutil/wchar_filename.h
+++ b/libavutil/wchar_filename.h
@@ -32,7 +32,8 @@ static inline int utf8towchar(const char *filename_utf8, wchar_t **filename_w)
num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0);
if (num_chars <= 0) {
*filename_w = NULL;
- return 0;
+ errno = EINVAL;
+ return -1;
}
*filename_w = (wchar_t *)av_calloc(num_chars, sizeof(wchar_t));
if (!*filename_w) {
@@ -52,7 +53,8 @@ static inline int wchartocp(unsigned int code_page, const wchar_t *filename_w,
NULL, 0, NULL, NULL);
if (num_chars <= 0) {
*filename = NULL;
- return 0;
+ errno = EINVAL;
+ return -1;
}
*filename = (char*)av_malloc_array(num_chars, sizeof *filename);
if (!*filename) {