Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes GetClipboardText() memory leak for PLATFORM_DESKTOP_SDL #4354

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

asdqwe
Copy link
Contributor

@asdqwe asdqwe commented Oct 1, 2024

SDL_GetClipboardText() must be freed with SDL_free() (doc), but that can't/shouldn't be done to a returned const.

Fix can be tested with:

#include "raylib.h"
int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {

        if (IsKeyPressed(KEY_ONE)) { TraceLog(LOG_INFO, "%s", GetClipboardText()); }

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

@raysan5 raysan5 merged commit d9c10ed into raysan5:master Oct 2, 2024
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Oct 2, 2024

@asdqwe Great improvement! Thanks!

@asdqwe asdqwe deleted the fix-clipboard-leak branch October 2, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants