shell32: Avoid leaks and add parameter checks in SHCreateShellFolderView[Ex].

Nikolay Sivov bunglehead at gmail.com
Sun Oct 20 12:12:44 CDT 2013


On 10/20/2013 21:01, Thomas Faber wrote:

> +    if (0)
> +    {
> +        // crash on win7
> +        pSHCreateShellFolderViewEx(NULL, NULL);
> +        pSHCreateShellFolderViewEx(NULL, &psv);
> +        pSHCreateShellFolderViewEx(&csfv, NULL);
> +    }
Please no cpp comments.

> +    MAKEFUNC_ORD(SHCreateShellFolderViewEx, 174);
> +    MAKEFUNC_ORD(SHCreateShellFolderView, 256);
These call are exported by name at least on XP, probably 2000 too, so it 
makes no sense to use ordinals here.

> +    if (!pSHCreateShellFolderView || !pSHCreateShellFolderViewEx)
> +    {
> +        win_skip("SHCreateShellFolderView or SHCreateShellFolderViewEx missing.\n");
> +        return;
> +    }
I don't think it's really possible to have *Ex version without non-Ex one.

> +    hr = SHGetDesktopFolder(&desktop);
> +    ok(hr == S_OK, "got (0x%08x)\n", hr);
> +    if (FAILED(hr))
> +    {
> +        skip("No desktop folder\n");
> +        return;
> +    }
It's not going to fail, so a ok() test is enough.

> +    memset(&sfvc, 0, sizeof(sfvc));
> +    sfvc.cbSize = sizeof(sfvc);
> +    sfvc.pshf = desktop;
> +    psv = (void *)0xdeadbeef;
> +    hr = pSHCreateShellFolderView(&sfvc, &psv);
> +    ok(hr == S_OK, "Got 0x%08x\n", hr);
> +    ok(psv != NULL, "psv = %p\n", psv);
> +    if (psv && psv != (void *)0xdeadbeef)
> +    {
> +        refCount = IShellView_Release(psv);
> +        ok(refCount == 0, "refCount = %u\n", refCount);
> +    }
It's simpler than that. Set 'psv' to NULL and test for it being set 
after a call.
> +    test_SHCreateShellFolderView();
You're testing two calls here, so they probably deserve two separate 
test functions.



More information about the wine-devel mailing list