Skip to content

fix mem leak in pasting name #6724

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

Merged
merged 1 commit into from
Oct 19, 2023
Merged

fix mem leak in pasting name #6724

merged 1 commit into from
Oct 19, 2023

Conversation

qndel
Copy link
Member

@qndel qndel commented Oct 19, 2023

Per https://wiki.libsdl.org/SDL2/SDL_GetClipboardText
Caller must call SDL_free() on the returned pointer when done with it (even if there was an error).
Also added checking if clipboard isn't empty

AJenbo
AJenbo previously approved these changes Oct 19, 2023
@AJenbo AJenbo enabled auto-merge (rebase) October 19, 2023 13:56
@AJenbo AJenbo merged commit 43766da into diasurgical:master Oct 19, 2023
SelheroCatToName(clipboard, UiTextInput, UiTextInputLen);
if (SDL_HasClipboardText() == SDL_TRUE) {
char *clipboard = SDL_GetClipboardText();
if (clipboard == nullptr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On failure, clipboard is not a nullptr but an empty string, so this check should be:

if (*clipboard == '\0') {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent #6730

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.

3 participants