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

fix memory leaks on ClipboardUtil::clipboard_text() and filesystem::base_path() #751

Merged
merged 1 commit into from
Feb 10, 2018
Merged

Conversation

kyren
Copy link
Contributor

@kyren kyren commented Feb 9, 2018

Namely SDL_GetBasePath and SDL_GetClipboardText.

For stupid reasons, we have to call SDL_GetClipboardText every frame, and we discovered a pretty bad memory leak if you HAPPENED to have large clipboard content.

There may be other errors of the same pattern, but I haven't looked for them.

namely SDL_GetBasePath and SDL_GetClipboardText
@Cobrand Cobrand changed the title call SDL_free on text buffers returned from a few SDL calls fix memory leaks on ClipboardUtil::clipboard_text() and filesystem::base_path() Feb 10, 2018
@Cobrand
Copy link
Member

Cobrand commented Feb 10, 2018

Funny how this went unnoticed for years while this is the very first line of the SDL2 documentation:

Use this function to get UTF-8 text from the clipboard, which must be freed with SDL_free()

Looks like the memory leaks happen anyway but they just get noticeable when you call this function hundreds of time and with large clipboard contents. Thanks for the PR, appreciate it! Will definitely need to check every call that returns text somehow in the future...

@Cobrand Cobrand merged commit 8f8813c into Rust-SDL2:master Feb 10, 2018
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