Skip to content

Commit

Permalink
Fixed crash if using clipboard functions without having initialized v…
Browse files Browse the repository at this point in the history
…ideo.
  • Loading branch information
philippwiesemann committed Feb 15, 2015
1 parent cec3efe commit ec2df64
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/video/SDL_clipboard.c
Expand Up @@ -29,6 +29,10 @@ SDL_SetClipboardText(const char *text)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();

if (!_this) {
return SDL_SetError("Video subsystem must be initialized to set clipboard text");
}

if (!text) {
text = "";
}
Expand All @@ -46,6 +50,11 @@ SDL_GetClipboardText(void)
{
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 {
Expand All @@ -62,6 +71,11 @@ SDL_HasClipboardText(void)
{
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 {
Expand Down

0 comments on commit ec2df64

Please sign in to comment.