ASAN: Fix leak in KAStatsFavoritesModel
ClosedPublic

Authored by kfunk on Nov 20 2018, 9:13 AM.

Details

Summary

Trace:
Direct leak of 336 byte(s) in 6 object(s) allocated from:

#0 0x544cc0 in operator new(unsigned long) (/home/kfunk/devel/install/kf5/bin/plasmashell+0x544cc0)
#1 0x7fbad15cddaf in KAStatsFavoritesModel::Private::entryForResource(QString const&) const /home/kfunk/devel/src/kf5/plasma-desktop/applets/kicker/plugin/kastatsfavoritesmodel.cpp:171:24
#2 0x7fbad15b2d8e in KAStatsFavoritesModel::Private::addResult(QString const&, int, bool) /home/kfunk/devel/src/kf5/plasma-desktop/applets/kicker/plugin/kastatsfavoritesmodel.cpp:280:22
#3 0x7fbad15b044f in KAStatsFavoritesModel::Private::Private(KAStatsFavoritesModel*, QString) /home/kfunk/devel/src/kf5/plasma-desktop/applets/kicker/plugin/kastatsfavoritesmodel.cpp:233:13
#4 0x7fbad15a78ea in KAStatsFavoritesModel::initForClient(QString const&) /home/kfunk/devel/src/kf5/plasma-desktop/applets/kicker/plugin/kastatsfavoritesmodel.cpp:485:13
...

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kfunk created this revision.Nov 20 2018, 9:13 AM
Restricted Application added a project: Plasma. · View Herald TranscriptNov 20 2018, 9:13 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
kfunk requested review of this revision.Nov 20 2018, 9:13 AM
ivan added a comment.Nov 21 2018, 5:15 PM

Using a shared pointer seems like a pessimization. Could this be done with std::unique_ptr?

kfunk added a comment.Nov 21 2018, 6:01 PM

I think the QSharedPointer overhead is very much negligible in this case here. And doesn't require refactoring of the original code. This is not performance sensitive code (compared to the costs of the QAIM-modifications), no?

If you think the memory leak can be fixed differently, shoot.

applets/kicker/plugin/kastatsfavoritesmodel.cpp
297

With std::unique_ptr we'd run into a couple of problems, like in this place here: Multiple copies would be needed.

ivan accepted this revision.Nov 21 2018, 6:18 PM

Ok, +2 from me then

This revision is now accepted and ready to land.Nov 21 2018, 6:18 PM
This revision was automatically updated to reflect the committed changes.