Skip to content

Commit

Permalink
Fixed segfault when reading an invalid/incomplete .desktop file (bsc#…
Browse files Browse the repository at this point in the history
…1090843)

When "X-SuSE-YaST-Group" value is missing or uses an unknown value
then it cannot be properly grouped in the view, so skip the invalid
files.
  • Loading branch information
lslezak committed May 11, 2018
1 parent 5ffd1c4 commit 9ad65f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/yqdesktopfilesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef QMapIterator<QString, QVariant> PropertyMapIterator;
// desktop file -> properties
typedef QMap<QString, PropertyMap > PropertyMapCache;
typedef QMapIterator<QString, PropertyMap> PropertyMapCacheIterator;
typedef QMutableMapIterator<QString, PropertyMap> PropertyMapCacheMutableIterator;

class cmp;

Expand Down
16 changes: 16 additions & 0 deletions src/yqmodulesmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,22 @@ void YQModulesModel::removeEmptyGroups()
groups << groupsModel()->groupId( idx );
}

// filter out the .desktop files with unknown or undefined group,
// otherwise grouping segfaults later
PropertyMapCacheMutableIterator it(d->cache);
while ( it.hasNext() )
{
it.next();
QString group = it.value().value("X-SuSE-YaST-Group").toString();
if ( !groups.contains( group ) )
{
QString file = it.key();
qWarning() << "Warning: Skipping file" << file << "with unknown group" << group;
d->desktop_files.removeAll( file );
it.remove();
}
}

QStringListIterator git(groups);
while (git.hasNext())
{
Expand Down

0 comments on commit 9ad65f2

Please sign in to comment.