dinput: Added a check for NULL callback in EnumDevices (try 2)
Lucas Fialho Zawacki
lfzawacki at gmail.com
Sat Jun 4 14:32:10 CDT 2011
Now testing explicitly for a DIERR_INVALIDPARAM in the return, also corrected
a typo in the test message.
---
dlls/dinput/dinput_main.c | 6 ++++++
dlls/dinput/tests/device.c | 2 ++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index d3727bc..46c3c9b 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -271,6 +271,9 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
+ if (!lpCallback)
+ return DIERR_INVALIDPARAM;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceA) continue;
for (j = 0, r = -1; r != 0; j++) {
@@ -302,6 +305,9 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
lpCallback, pvRef, dwFlags);
_dump_EnumDevices_dwFlags(dwFlags);
+ if (!lpCallback)
+ return DIERR_INVALIDPARAM;
+
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceW) continue;
for (j = 0, r = -1; r != 0; j++) {
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c
index a8ff19b..0fb66fa 100644
--- a/dlls/dinput/tests/device.c
+++ b/dlls/dinput/tests/device.c
@@ -187,6 +187,8 @@ static void device_tests(void)
hr = IDirectInput_EnumDevices(pDI, 0, enum_devices, &data, DIEDFL_ALLDEVICES);
ok(SUCCEEDED(hr), "IDirectInput_EnumDevices() failed: %08x\n", hr);
+ hr = IDirectInput_EnumDevices(pDI, 0, NULL, &data, DIEDFL_ALLDEVICES);
+ ok(hr == DIERR_INVALIDPARAM, "IDirectInput_EnumDevices() succeeded with NULL callback: %08x\n", hr);
/* If GetDeviceStatus returns DI_OK the device must exist */
hr = IDirectInput_GetDeviceStatus(pDI, &GUID_Joystick);
--
1.7.0.4
More information about the wine-patches
mailing list