libadm icon indicating copy to clipboard operation
libadm copied to clipboard

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

Open tomjnixon opened this issue 3 years ago • 2 comments

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.

tomjnixon avatar Nov 25 '21 19:11 tomjnixon

So

https://github.com/ebu/libadm/blob/4703bdc3fab08011fa9be44334e11122308a2fee/src/elements/audio_content.cpp#L96-L98

should be

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

?

rsjbailey avatar Dec 01 '21 13:12 rsjbailey

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

tomjnixon avatar Dec 06 '21 10:12 tomjnixon