From 23db1922963ae91b68d037e0946cf0e05046055d Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Wed, 16 Mar 2022 02:12:10 -0700 Subject: [PATCH] SDL2_Platform::get_clipboard was not freeing --- src/internal/platform_sdl2.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/internal/platform_sdl2.cpp b/src/internal/platform_sdl2.cpp index a6de913..5a8a754 100644 --- a/src/internal/platform_sdl2.cpp +++ b/src/internal/platform_sdl2.cpp @@ -78,6 +78,7 @@ namespace Blah SDL_GameController* gamepads[Input::max_controllers]; char* base_path_value = nullptr; char* user_path_value = nullptr; + char* clipboard_text = nullptr; bool displayed = false; SDL2_Platform(); @@ -243,6 +244,9 @@ void SDL2_Platform::shutdown() if (user_path_value != nullptr) SDL_free(user_path_value); + if (clipboard_text != nullptr) + SDL_free(clipboard_text); + SDL_Quit(); } @@ -669,7 +673,12 @@ void SDL2_Platform::set_clipboard(const char* text) const char* SDL2_Platform::get_clipboard() { - return SDL_GetClipboardText(); + // free previous clipboard text + if (clipboard_text != nullptr) + SDL_free(clipboard_text); + + clipboard_text = SDL_GetClipboardText(); + return clipboard_text; } void* SDL2_Platform::gl_get_func(const char* name)