Fixed crash if using clipboard functions without having initialized video.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Sun, 15 Feb 2015 11:35:07 +0100
changeset 9349 7674af9a59c8
parent 9348 7bda52b051f9
child 9350 419c75bb3cd4
Fixed crash if using clipboard functions without having initialized video.
src/video/SDL_clipboard.c
--- a/src/video/SDL_clipboard.c	Sun Feb 15 11:33:39 2015 +0100
+++ b/src/video/SDL_clipboard.c	Sun Feb 15 11:35:07 2015 +0100
@@ -29,6 +29,10 @@
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
 
+    if (!_this) {
+        return SDL_SetError("Video subsystem must be initialized to set clipboard text");
+    }
+
     if (!text) {
         text = "";
     }
@@ -46,6 +50,11 @@
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
 
+    if (!_this) {
+        SDL_SetError("Video subsystem must be initialized to get clipboard text");
+        return SDL_strdup("");
+    }
+
     if (_this->GetClipboardText) {
         return _this->GetClipboardText(_this);
     } else {
@@ -62,6 +71,11 @@
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
 
+    if (!_this) {
+        SDL_SetError("Video subsystem must be initialized to check clipboard text");
+        return SDL_FALSE;
+    }
+
     if (_this->HasClipboardText) {
         return _this->HasClipboardText(_this);
     } else {