Skip to content

possible null pointer dereference in sfRenderTexture_destroy#340

Merged
ChrisThrasher merged 1 commit intoSFML:masterfrom
ZXShady:null_dereference_on_destroy
Sep 18, 2024
Merged

possible null pointer dereference in sfRenderTexture_destroy#340
ChrisThrasher merged 1 commit intoSFML:masterfrom
ZXShady:null_dereference_on_destroy

Conversation

@ZXShady
Copy link
Copy Markdown
Contributor

@ZXShady ZXShady commented Sep 18, 2024

void sfRenderTexture_destroy(const sfRenderTexture* renderTexture)
{
    delete renderTexture->Target;
    delete renderTexture;
}

if renderTexture is null then we are dereferencing a null pointer, so I fixed it by making Target a std::unique_ptr instead of if(renderTexture) delete renderTexture->Target check and it better resembles the ownership model.

@ChrisThrasher ChrisThrasher force-pushed the null_dereference_on_destroy branch from e8a9de5 to 30eb230 Compare September 18, 2024 14:40
@ChrisThrasher ChrisThrasher merged commit 082a90e into SFML:master Sep 18, 2024
@eXpl0it3r eXpl0it3r added this to the 3.0 milestone Sep 18, 2024
@ZXShady ZXShady deleted the null_dereference_on_destroy branch September 28, 2024 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants