[Win] Avoid NRE in WinFactory.Dispose()
authorthefiddler <stapostol@gmail.com>
Tue, 23 Sep 2014 06:55:02 +0000 (08:55 +0200)
committerthefiddler <stapostol@gmail.com>
Tue, 23 Sep 2014 06:55:02 +0000 (08:55 +0200)
WinFactory.Dispose() could crash with a NRE when the joystick driver has
not been initialized. Fixed by checking for null before disposing the
input driver.

Source/OpenTK/Platform/Windows/WinFactory.cs

index d09b4de..6f57024 100644 (file)
@@ -163,7 +163,12 @@ namespace OpenTK.Platform.Windows
             {
                 if (manual)
                 {
-                    rawinput_driver.Dispose();
+                    WinRawInput raw = rawinput_driver;
+                    if (raw != null)
+                    {
+                        raw.Dispose();
+                        rawinput_driver = null;
+                    }
                 }
 
                 base.Dispose(manual);