From: Jeff Smith whydoubt@gmail.com
--- dlls/ddraw/device.c | 22 ++++++++++++---------- dlls/ddraw/tests/ddraw1.c | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 586d189d882..3c8aefd2307 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -1091,21 +1091,23 @@ static HRESULT WINAPI d3d_device1_GetPickRecords(IDirect3DDevice *iface,
TRACE("iface %p, count %p, records %p.\n", iface, count, records);
+ /* This causes an exception on Windows */ + if (!count) + { + ERR("count is NULL, returning DDERR_INVALIDPARAMS\n"); + return DDERR_INVALIDPARAMS; + } + wined3d_mutex_lock();
device = impl_from_IDirect3DDevice(iface);
- /* Set count to the number of pick records we have */ - *count = device->pick_record_count; - - /* It is correct usage according to documentation to call this function with records == NULL - to retrieve _just_ the record count, which the caller can then use to allocate an - appropriately sized array, then call this function again to fill that array with data. */ - if (records && count) - { - /* If we have a destination array and records to copy, copy them now */ + /* If passed-in count does not match, fix it and do nothing else */ + if (*count != device->pick_record_count) + *count = device->pick_record_count; + /* If we have a destination array and records to copy, copy them now */ + else if (records) memcpy(records, device->pick_records, sizeof(*device->pick_records) * device->pick_record_count); - }
wined3d_mutex_unlock();
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 1ce8c6bf71b..fcf500ed0a9 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -15585,9 +15585,9 @@ static void test_pick(void) hr = IDirect3DDevice_GetPickRecords(device, &rec_count, &record[0]); ok(SUCCEEDED(hr), "Failed to get pick records, hr %#lx.\n", hr); ok(rec_count == 3, "Got incorrect number of pick records (expected 3): %lu.\n", rec_count); - todo_wine ok(memcmp(&record[0], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); - todo_wine ok(memcmp(&record[1], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); - todo_wine ok(memcmp(&record[2], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + ok(memcmp(&record[0], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + ok(memcmp(&record[1], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n"); + ok(memcmp(&record[2], &empty_record, sizeof(D3DPICKRECORD)) == 0, "Got unexpected pick record.\n");
rec_count = 3; hr = IDirect3DDevice_GetPickRecords(device, &rec_count, &record[0]);