pfultz2/cppcheck

FP lifetime: derefencing iterator

pfultz2 opened this issue · 2 comments

Gtk::TreeModel::Path JDTreeViewBase::get_current_path()
{
    Gtk::TreeModel::Path path;
    
    std::list< Gtk::TreeModel::Path > paths = get_selection()->get_selected_rows();
    if( paths.size() ){
    
        std::list< Gtk::TreeModel::Path >::iterator it = paths.begin();
        path = ( *it );
    }

    return path;
}
class VariableDefinition*
VariableStackMap::find (const char* name) const
{
  Map::const_iterator i = myMap.find (name);
  if (i == myMap.end ())
    return NULL;

  const Stack& s = (*i).second;
  if (s.empty ())
    return NULL;

  return *s.begin ();
}
int ColumnResizer::getFitCount(int nCol, int nWidth) const
{
    const vector<int>& v (m_vvAllWidths[nCol]);
    vector<int>::const_iterator it (lower_bound(v.begin(), v.end(), nWidth));
    return it - v.begin();
}