Skip to content
Permalink
Browse files

[c-host] not all versions of mingw support wcstombs_s

While the _s functions are for security as they avoid exceeding the
supplied buffer, in our case they are not really required as we are
allocating a buffer large enough to store the entire result.

Fixes #171
  • Loading branch information...
gnif committed Jun 12, 2019
1 parent e3343cb commit 6d24dd52d63847b041430eeafd17a305060a0573
Showing with 4 additions and 7 deletions.
  1. +1 −1 VERSION
  2. +2 −4 c-host/platform/Windows/capture/DXGI/src/dxgi.c
  3. +1 −2 c-host/platform/Windows/src/platform.c
@@ -1 +1 @@
B1-rc5-5-g113da121e9+1
B1-rc5-8-ge3343cbd01+1
@@ -215,9 +215,8 @@ static bool dxgi_init(void * pointerShape, const unsigned int pointerSize)
IDXGIAdapter1_GetDesc1(this->adapter, &adapterDesc);

const size_t s = (wcslen(adapterDesc.Description)+1) * 2;
size_t unused;
char * desc = malloc(s);
wcstombs_s(&unused, desc, s, adapterDesc.Description, _TRUNCATE);
wcstombs(desc, adapterDesc.Description, s);

if (strstr(desc, optAdapter) == NULL)
{
@@ -238,9 +237,8 @@ static bool dxgi_init(void * pointerShape, const unsigned int pointerSize)
if (optOutput)
{
const size_t s = (wcslen(outputDesc.DeviceName)+1) * 2;
size_t unused;
char * desc = malloc(s);
wcstombs_s(&unused, desc, s, outputDesc.DeviceName, _TRUNCATE);
wcstombs(desc, outputDesc.DeviceName, s);

if (strstr(desc, optOutput) == NULL)
{
@@ -194,9 +194,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
for(int i = 0; i < app.argc; ++i)
{
const size_t s = (wcslen(wargv[i])+1) * 2;
size_t unused;
app.argv[i] = malloc(s);
wcstombs_s(&unused, app.argv[i], s, wargv[i], _TRUNCATE);
wcstombs(app.argv[i], wargv[i], s);
}
LocalFree(wargv);

0 comments on commit 6d24dd5

Please sign in to comment.
You can’t perform that action at this time.