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

libobs: Fix guards in obs.c #1339

Closed
wants to merge 1 commit into from

Conversation

kkartaltepe
Copy link
Collaborator

Fixes some unfortunately ordered guards that dereferenced obs before checking it is valid
Unifies some of the guard formatting

(totally didnt test this as I just noticed it when skimming. So im praying i didnt make a dumb typo, and relying on CI to check for it)

Fixes some unfortunately ordered guards that dereferenced `obs` before checking it is valid
Unifies some of the guard formatting
@jp9000
Copy link
Member

jp9000 commented Jun 20, 2018

Thank you, although this pull request is unnecessary. The reason is because of the following:

    struct obs_core_video *video = &obs->video;

In this statement, there is no actual dereferencing. When the obs pointer in this line is NULL, it does not crash; it will simply set the local variable, video, to the the offset of the obs_core::video member variable. See https://en.wikipedia.org/wiki/Offsetof -- that is why it's safe to have the if (!obs) return; statements after rather than before.

@jp9000 jp9000 closed this Jun 20, 2018
@kkartaltepe
Copy link
Collaborator Author

No worries, Thanks for taking a look.

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