ddraw/tests: Don't crash after a failed CreateSurface() call.

Henri Verbeet hverbeet at gmail.com
Thu Feb 27 07:59:51 CST 2014


On 27 February 2014 02:46, Francois Gouget <fgouget at codeweavers.com> wrote:
> Is there a way to check what surface types are supported?
In theory, but in practice the most reliable way seems to be calling
CreateSurface() and seeing if it works.

Unfortunately the correct way to fix these depends a bit on the
specific case. E.g.:
> @@ -4817,6 +4819,8 @@ static void test_set_surface_desc(void)
>
>      hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
>      ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
> +    if (FAILED(hr))
> +        goto done;
>
>      hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
>      ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
> @@ -5113,6 +5117,12 @@ static void test_user_memory_getdc(void)
>      ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
>      hr = IDirectDraw2_CreateSurface(ddraw, &ddsd, &surface, NULL);
>      ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
> +    if (FAILED(hr))
> +    {
> +        IDirectDraw2_Release(ddraw);
> +        DestroyWindow(window);
> +        return;
> +    }
>
>      hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3);
>      ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr);
These can be fixed by adding DDSCAPS_OFFSCREENPLAIN to ddsd.ddsCaps.dwCaps.



More information about the wine-devel mailing list