mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
decklink: Fix broken COM string conversion
WideCharToMultiByte return is the string length without null terminate character if passed "cchWideChar" does not include the null terminate character size. Instead of passing the exact string length, pass -1 so that the API can understand the input string is null terminated already and returned value from the API includes the character. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3023 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5444>
This commit is contained in:
parent
c020dab393
commit
3536b7f3a6
1 changed files with 4 additions and 6 deletions
|
@ -37,19 +37,17 @@
|
||||||
#define COMSTR_T BSTR
|
#define COMSTR_T BSTR
|
||||||
#define CONVERT_COM_STRING(s) G_STMT_START { \
|
#define CONVERT_COM_STRING(s) G_STMT_START { \
|
||||||
BSTR _s = (BSTR)s; \
|
BSTR _s = (BSTR)s; \
|
||||||
int _s_length = ::SysStringLen(_s); \
|
int _length = ::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, -1, NULL, 0, NULL, NULL); \
|
||||||
int _length = ::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, _s_length, NULL, 0, NULL, NULL); \
|
|
||||||
s = (char *) malloc(_length); \
|
s = (char *) malloc(_length); \
|
||||||
::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, _s_length, s, _length, NULL, NULL); \
|
::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, -1, s, _length, NULL, NULL); \
|
||||||
::SysFreeString(_s); \
|
::SysFreeString(_s); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
#define FREE_COM_STRING(s) free(s);
|
#define FREE_COM_STRING(s) free(s);
|
||||||
#define CONVERT_TO_COM_STRING(s) G_STMT_START { \
|
#define CONVERT_TO_COM_STRING(s) G_STMT_START { \
|
||||||
char * _s = (char *)s; \
|
char * _s = (char *)s; \
|
||||||
int _s_length = strlen((char*)_s); \
|
int _length = ::MultiByteToWideChar(CP_ACP, 0, (char*)_s, -1, NULL, 0); \
|
||||||
int _length = ::MultiByteToWideChar(CP_ACP, 0, (char*)_s, _s_length, NULL, 0); \
|
|
||||||
s = ::SysAllocStringLen(NULL, _length); \
|
s = ::SysAllocStringLen(NULL, _length); \
|
||||||
::MultiByteToWideChar(CP_ACP, 0, (char*)_s, _s_length, s, _length); \
|
::MultiByteToWideChar(CP_ACP, 0, (char*)_s, -1, s, _length); \
|
||||||
g_free(_s); \
|
g_free(_s); \
|
||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
|
Loading…
Reference in a new issue