Skip to content

Commit

Permalink
Fixed crash if num_mime_types is NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 31, 2024
1 parent e74f404 commit 36806d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/video/SDL_clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,18 @@ char **SDL_GetClipboardMimeTypes(size_t *num_mime_types)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();

if (num_mime_types) {
*num_mime_types = 0;
}

if (!_this) {
SDL_SetError("Video subsystem must be initialized to query clipboard mime types");
SDL_SetError("Video subsystem has not been initialized");
return NULL;
}

*num_mime_types = _this->num_clipboard_mime_types;
if (num_mime_types) {
*num_mime_types = _this->num_clipboard_mime_types;
}
return SDL_CopyClipboardMimeTypes((const char **)_this->clipboard_mime_types, _this->num_clipboard_mime_types, false);
}

Expand Down

0 comments on commit 36806d9

Please sign in to comment.