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

[Common/Core/Windows] Removed excess check pointer before delete or free() #19045

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GermanAizek
Copy link
Contributor

This method rechecking ptr came from C, now it doesn't make sense in C++, you can make cleaner and less code.
More info in this answer: https://stackoverflow.com/a/615408

@anr2me
Copy link
Collaborator

anr2me commented Apr 12, 2024

Probably to avoid deleting/freeing an already freed/deleted pointer, if there are another clean up code somewhere else that set the pointer to null (since delete/free doesn't set the pointer to null automatically, you can findout whether there are codes that intentionally set it to NULL/nullptr/0).

Also, if it involves a PSP syscall, sometime games could called somethingTerm syscall multiple times (either due to a bug or unexpected returned value causing the game to behave strangely), which could attempt to clean up something more than once.

So, you will need to test this changes to make sure it doesn't cause a crash due to an attempt to free/delete an already freed/deleted allocation.

@GermanAizek
Copy link
Contributor Author

Probably to avoid deleting/freeing an already freed/deleted pointer, if there are another clean up code somewhere else that set the pointer to null (since delete/free doesn't set the pointer to null automatically).

Also, if it involves a PSP syscall, sometime games could called somethingTerm syscall multiple times (either due to a bug or unexpected returned value causing the game to behave strangely), which could attempt to clean up something more than once.

So, you will need to test this changes to make sure it doesn't cause a crash due to an attempt to free/delete an already freed/deleted allocation.

Well, I tried to restart game images, go to different menus, there were no problems playing completely.

image

@anr2me
Copy link
Collaborator

anr2me commented Apr 12, 2024

Ah right, if there are codes that intentionally set those pointer to NULL/nullptr/0 after freeing/deleting them somewhere else, it should be safe to delete/free them again without checking.
So, this changes should be okay i guess.

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.

None yet

2 participants