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

Remove unnecessary null pointer checks #38

Open
elfring opened this issue Mar 26, 2016 · 6 comments
Open

Remove unnecessary null pointer checks #38

elfring opened this issue Mar 26, 2016 · 6 comments

Comments

@elfring
Copy link

elfring commented Mar 26, 2016

An extra null pointer check is not needed in functions like the following.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Xender
Copy link

Xender commented Mar 26, 2016

+1, but I'd also like to remark that while checking for null pointer before delete is unnecessary, it could be a good idea to set the pointer to null after the deletion, to avoid potential use-after-free errors.

So using the code fragments from OP:
Here the pointer is set to null after deleting the pointed object.
Here it's not - although this one is in the destructor, so omitting it here is far less risky than omitting it somewhere else.

Also, using smart pointers (#39) instead of "naked" new/delete could provide even more defense against bugs.

@RodneyBaker

This comment has been minimized.

@RodneyBaker
Copy link
Collaborator

RodneyBaker commented Jul 28, 2019

Updated: This issue gets the award for being the oldest Issue reported that is still open (as of 20200329)

@RodneyBaker
Copy link
Collaborator

Given the years that have passed since this question was asked the answer would appear to be 'no' or 'not at this time'.
Perhaps the question can be restated.

@elfring
Copy link
Author

elfring commented Sep 25, 2022

@RodneyBaker
Copy link
Collaborator

Given the years that have passed I can't think of an appropriate candidate.

Given how many developers have looked at the code (and related concerns) a still decided to pass on the more trivial changes... important though they may be.... I can say with some assurance that interest is low. This does not suggest it always will be however as seen in the occassional PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants