soreau/SDL — pull request #17 by thp (2013-07-09 09:25:38+00:00)
Title: wayland: Fix crash when wayland server is not running

Fix two ```NULL``` pointer dereferencing crashes in ```Wayland_VideoQuit```.

How to reproduce the bug (and verify it is fixed with this patch):

* Build SDL2 with ```--enable-video-wayland --disable-video-x11```
* ```export SDL_VIDEODRIVER=wayland```
* Make sure no wayland server is running (and unset ```WAYLAND_DISPLAY```)
* Build this simple test application:

```
#include

int
main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
return 0;
}
```

* Without this patch, the test application crashes:

```
#0 0x00000031e5c04fc9 in wl_proxy_destroy ()
from /lib64/libwayland-client.so.0
#1 0x00007ffff7dcc64e in wl_output_destroy (wl_output=)
at /usr/include/wayland-client-protocol.h:2107
#2 Wayland_VideoQuit (_this=0x6020c0)
at ../src/video/wayland/SDL_waylandvideo.c:279
#3 0x00007ffff7dc387e in SDL_VideoQuit () at ../src/video/SDL_video.c:2227
#4 0x00007ffff7dc3e73 in SDL_VideoInit (driver_name=,
driver_name@entry=0x0) at ../src/video/SDL_video.c:517
#5 0x00007ffff7d2cecf in SDL_InitSubSystem (flags=flags@entry=32)
at ../src/SDL.c:121
#6 0x00007ffff7d2cf5c in SDL_Init (flags=32) at ../src/SDL.c:216
#7 0x0000000000400709 in main ()
```

Tested with wayland 1.1.90-0.1.20130515 on Fedora 19.