diff --git a/src/lib/deskflow/IKeyState.cpp b/src/lib/deskflow/IKeyState.cpp index 287d696bf..e5d3aa270 100644 --- a/src/lib/deskflow/IKeyState.cpp +++ b/src/lib/deskflow/IKeyState.cpp @@ -44,7 +44,13 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( const char *buffer = screens.c_str(); // build structure +#if SYSAPI_WIN32 + // On windows we use malloc to avoid random test failures + auto *info = (KeyInfo *)malloc(sizeof(KeyInfo) + screens.size()); +#else auto *info = new KeyInfo(); +#endif + info->m_key = id; info->m_mask = mask; info->m_button = button; @@ -57,7 +63,14 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(const KeyInfo &x) { auto bufferLen = strnlen(x.m_screensBuffer, SIZE_MAX); + +#if SYSAPI_WIN32 + // On windows we use malloc to avoid random test failures + auto info = (KeyInfo *)malloc(sizeof(KeyInfo) + bufferLen); +#else auto *info = new KeyInfo(); +#endif + info->m_key = x.m_key; info->m_mask = x.m_mask; info->m_button = x.m_button;