Skip to content

[lldb] Add checks before dereferencing (NFC) #2528

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
Feb 19, 2021

Conversation

kastiglione
Copy link

Fix a potential null dereference identified by @adrian-prantl, and also check the target too before dereferencing.

rdar://74371588

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

kastiglione commented Feb 19, 2021

@adrian-prantl Is it worth keeping the check on the target? If there's a valid exe_scope, is a target guaranteed? If a target is guaranteed, maybe the return type of CalculateTarget should be Target &. EDIT: I see now it can't be Thread &.

@adrian-prantl
Copy link

@adrian-prantl Is it worth keeping the check on the target? If there's a valid exe_scope, is a target guaranteed? If a target is guaranteed, maybe the return type of CalculateTarget should be Target &. EDIT: I see now it can't be Thread &.

My understanding is that an ExecutionScope implies a Target. But — even if that's the case now, I'm strongly leaning towards checking everything that can be null because this may not be true in the future. In short: If it's guaranteed, the API should a reference. If it returns a pointer, we must check it.

@adrian-prantl adrian-prantl merged commit 31ae58c into swift/main Feb 19, 2021
@kastiglione kastiglione deleted the lldb-Add-checks-before-dereferencing-NFC branch February 19, 2021 18:49
@kastiglione
Copy link
Author

If it returns a pointer, we must check it.

agreed

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