[Coverity 1313710] Unchecked dynamic_cast in M3U8.cpp
If the dynamic_cast fails, a null pointer dereference will occur; if the dynamic_cast cannot fail, using static_cast instead offers better performance.
In hls::playlist::M3U8::isLive(): Dynamic_cast may fail and return null if the type cast is incompatible (CWE-476)
1. Condition itp != std::vector<adaptive::playlist::BasePeriod *, std::allocator<adaptive::playlist::BasePeriod *> >::const_iterator(this->periods.end()), taking true branch.
45 for(itp = periods.begin(); itp != periods.end(); ++itp)
46 {
47 const BasePeriod *period = *itp;
48 const std::vector<BaseAdaptationSet *> &sets = period->getAdaptationSets();
2. Condition ita != std::vector<adaptive::playlist::BaseAdaptationSet *, std::allocator<adaptive::playlist::BaseAdaptationSet *> >::const_iterator(sets->cend()), taking true branch.
49 for(auto ita = sets.cbegin(); ita != sets.cend(); ++ita)
50 {
51 BaseAdaptationSet *adaptSet = *ita;
52 const std::vector<BaseRepresentation *> &reps = adaptSet->getRepresentations();
3. Condition itr != std::vector<adaptive::playlist::BaseRepresentation *, std::allocator<adaptive::playlist::BaseRepresentation *> >::const_iterator(reps->cend()), taking true branch.
53 for(auto itr = reps.cbegin(); itr != reps.cend(); ++itr)
54 {
4. dynamic_cast: Dynamic cast to pointer dynamic_cast <hls::playlist::HLSRepresentation const *>(*itr) can return NULL.
5. alias_transfer: Assigning: rep = dynamic_cast <hls::playlist::HLSRepresentation const *>(*itr).
55 const HLSRepresentation *rep = dynamic_cast<const HLSRepresentation *>(*itr);
CID 1313710: (#1 of 1): Unchecked dynamic_cast (FORWARD_NULL)
6. var_deref_model: Passing null pointer rep to initialized, which dereferences it.[show details]
56 if(rep->initialized())