# SDL: Set size parameter in SDL\_GetClipboardData()

**URL:** <https://discourse.libsdl.org/t/sdl-set-size-parameter-in-sdl-getclipboarddata/54932>\
**Category:** SDL Commits\
**Created:** [October 13, 2024, 3:59pm UTC](https://discourse.libsdl.org/t/sdl-set-size-parameter-in-sdl-getclipboarddata/54932 "2024-10-13T15:59:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 13, 2024, 3:59pm UTC](https://discourse.libsdl.org/t/sdl-set-size-parameter-in-sdl-getclipboarddata/54932/1 "2024-10-13T15:59:53Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/1a1e2e9892af6eb0be79eaff60e774dd29951fb8>
>
> Update size value in case where platform uses GetClipboardText().
> This should fi…x clipboard\_testClipboardDataFunctions on those platforms.

```diff
From 1a1e2e9892af6eb0be79eaff60e774dd29951fb8 Mon Sep 17 00:00:00 2001
From: capehill <[EMAIL REDACTED]>
Date: Sun, 13 Oct 2024 13:17:33 +0300
Subject: [PATCH] Set size parameter in SDL_GetClipboardData()

Update size value in case where platform uses GetClipboardText().
This should fix clipboard_testClipboardDataFunctions on those platforms.
---
 src/video/SDL_clipboard.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c
index 9d663980bf49d..93493673585ab 100644
--- a/src/video/SDL_clipboard.c
+++ b/src/video/SDL_clipboard.c
@@ -196,9 +196,13 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size)
         return _this->GetClipboardData(_this, mime_type, size);
     } else if (_this->GetClipboardText && SDL_IsTextMimeType(mime_type)) {
         char *text = _this->GetClipboardText(_this);
- if (text && *text == '\0') {
- SDL_free(text);
- text = NULL;
+ if (text) {
+ if (*text == '\0') {
+ SDL_free(text);
+ text = NULL;
+ } else {
+ *size = SDL_strlen(text);
+ }
         }
         return text;
     } else {

```
