[PATCH] winealsa.drv: Don't crash when getting NULL event from midi

Andrew Eikum aeikum at codeweavers.com
Tue Nov 20 12:41:19 CST 2018


On Tue, Nov 20, 2018 at 06:48:08PM +0100, Fabian Maurer wrote:
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46170
> Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
> ---
>  dlls/winealsa.drv/midi.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/dlls/winealsa.drv/midi.c b/dlls/winealsa.drv/midi.c
> index 3d4d933ead..a594f5af70 100644
> --- a/dlls/winealsa.drv/midi.c
> +++ b/dlls/winealsa.drv/midi.c
> @@ -328,6 +328,10 @@ static DWORD WINAPI midRecThread(LPVOID arg)
>              EnterCriticalSection(&midiSeqLock);
>  	    snd_seq_event_input(midiSeq, &ev);
>              LeaveCriticalSection(&midiSeqLock);
> +
> +            if (!ev)
> +                continue;
> +

Interesting. I worry this might loop forever, since we never modify
the do-while condition during a snd_seq_event_input->continue loop.

You could use a goto, but a less ugly change would be to move the ev
handling into a function and call that iff ev is non-NULL.

(Also please be mindful of keeping indentation as consistent as
possible. IMO ideally each function is consistent, though I know
others have other opinions.)

Thanks,
Andrew



More information about the wine-devel mailing list