Skip to content

Commit

Permalink
Better error checking for DeviceData
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jun 18, 2024
1 parent 7b3b689 commit f31e8dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 67
#define BUILD_NUMBER 68
8 changes: 4 additions & 4 deletions IDirectInputDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ HRESULT m_IDirectInputDeviceX::GetDeviceData(DWORD cbObjectData, LPDIDEVICEOBJEC
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";

// If just peeking at data
if (dwFlags == DIGDD_PEEK || !rgdod)
// If just peeking or clearing data
if (dwFlags == DIGDD_PEEK || !rgdod || (pdwInOut && *pdwInOut == INFINITE))
{
return ProxyInterface->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), rgdod, pdwInOut, dwFlags);
}

// Check for valid parameters
if (!pdwInOut || !*pdwInOut || *pdwInOut == (DWORD)-1 || !cbObjectData)
if (!pdwInOut || !*pdwInOut || (cbObjectData != sizeof(DIDEVICEOBJECTDATA_DX3) && cbObjectData != sizeof(DIDEVICEOBJECTDATA)))
{
return DIERR_INVALIDPARAM;
}
Expand Down Expand Up @@ -805,7 +805,7 @@ HRESULT m_IDirectInputDeviceX::SendDeviceData(DWORD cbObjectData, LPCDIDEVICEOBJ
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";

if (!pdwInOut || !rgdod || !cbObjectData)
if (!pdwInOut || !rgdod || (cbObjectData != sizeof(DIDEVICEOBJECTDATA_DX3) && cbObjectData != sizeof(DIDEVICEOBJECTDATA)))
{
return DIERR_INVALIDPARAM;
}
Expand Down

0 comments on commit f31e8dd

Please sign in to comment.