SDL2_Platform::get_clipboard was not freeing

This commit is contained in:
Noel Berry 2022-03-16 02:12:10 -07:00
parent d482840cfe
commit 23db192296

View File

@ -78,6 +78,7 @@ namespace Blah
SDL_GameController* gamepads[Input::max_controllers]; SDL_GameController* gamepads[Input::max_controllers];
char* base_path_value = nullptr; char* base_path_value = nullptr;
char* user_path_value = nullptr; char* user_path_value = nullptr;
char* clipboard_text = nullptr;
bool displayed = false; bool displayed = false;
SDL2_Platform(); SDL2_Platform();
@ -243,6 +244,9 @@ void SDL2_Platform::shutdown()
if (user_path_value != nullptr) if (user_path_value != nullptr)
SDL_free(user_path_value); SDL_free(user_path_value);
if (clipboard_text != nullptr)
SDL_free(clipboard_text);
SDL_Quit(); SDL_Quit();
} }
@ -669,7 +673,12 @@ void SDL2_Platform::set_clipboard(const char* text)
const char* SDL2_Platform::get_clipboard() 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) void* SDL2_Platform::gl_get_func(const char* name)