[PATCH] mmdevapi/tests: Prevent crash when GetMixFormat fails.

Alexandre Julliard julliard at winehq.org
Thu Jul 29 10:50:53 CDT 2010


Octavian Voicu <octavian.voicu at gmail.com> writes:

> @@ -190,25 +190,31 @@ static void test_audioclient(IAudioClient *ac)
>      hr = IAudioClient_GetMixFormat(ac, NULL);
>      ok(hr == E_POINTER, "GetMixFormat returns %08x\n", hr);
>  
> +    pwfx = (void *)0xdeadbeef;
>      hr = IAudioClient_GetMixFormat(ac, &pwfx);
>      ok(hr == S_OK, "Valid GetMixFormat returns %08x\n", hr);
>  
> -    trace("Tag: %04x\n", pwfx->wFormatTag);
> -    trace("bits: %u\n", pwfx->wBitsPerSample);
> -    trace("chan: %u\n", pwfx->nChannels);
> -    trace("rate: %u\n", pwfx->nSamplesPerSec);
> -    trace("align: %u\n", pwfx->nBlockAlign);
> -    trace("extra: %u\n", pwfx->cbSize);
> -    ok(pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE, "wFormatTag is %x\n", pwfx->wFormatTag);
> -    if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
> +    trace("pwfx: %p\n", pwfx);
> +    if (pwfx == (void *)0xdeadbeef) pwfx = NULL;
> +    if (pwfx)

That's ugly, you should check the function result, not a magic pointer
value.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list