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

set(AudioContentId) calls getParent().lock()->lookup(id) without checking for nullptr #124

Open
tomjnixon opened this issue Nov 25, 2021 · 2 comments

Comments

@tomjnixon
Copy link
Member

It does check for nullptr before doing this, but it could have been removed in the meantime.

This is probably the same for the other types.

@rsjbailey
Copy link
Contributor

So

if (getParent().lock() != nullptr && getParent().lock()->lookup(id)) {
throw std::runtime_error("id already in use");
}

should be

{
  auto parent = getParent().lock();
  if(parent && parent->lookup(id)) {
    throw std::runtime_error("id already in use"); 
  }
}

?

@tomjnixon
Copy link
Member Author

Yeah, exactly. In practice it's fine in single-threaded code, but I have to think about it every time I see it.

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

No branches or pull requests

2 participants