Browse Source

Allow a NULL size parameter to retrieve null terminated text

Sam Lantinga 7 months ago
parent
commit
30a22d3fed
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/video/SDL_clipboard.c

+ 2 - 2
src/video/SDL_clipboard.c

@@ -174,6 +174,7 @@ void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type
 void *SDL_GetClipboardData(const char *mime_type, size_t *size)
 void *SDL_GetClipboardData(const char *mime_type, size_t *size)
 {
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    size_t unused;
 
 
     if (!_this) {
     if (!_this) {
         SDL_UninitializedVideo();
         SDL_UninitializedVideo();
@@ -185,8 +186,7 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size)
         return NULL;
         return NULL;
     }
     }
     if (!size) {
     if (!size) {
-        SDL_InvalidParamError("size");
-        return NULL;
+        size = &unused;
     }
     }
 
 
     // Initialize size to empty, so implementations don't have to worry about it
     // Initialize size to empty, so implementations don't have to worry about it