Review Request 122393: Fix dangling pointer and possible memory leak in knotifications
Xuetian Weng
wengxt at gmail.com
Mon Feb 2 21:08:11 UTC 2015
> On Feb. 2, 2015, 9:05 p.m., Martin Klapetek wrote:
> > src/notifybypopup.cpp, lines 485-495
> > <https://git.reviewboard.kde.org/r/122393/diff/2/?file=346479#file346479line485>
> >
> > Can you explain this change in a bit more detail?
Well.. I just randomly notice this. line 470 might return and watcher won't be deleted in that case.
- Xuetian
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122393/#review75238
-----------------------------------------------------------
On Feb. 2, 2015, 8:59 p.m., Xuetian Weng wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/122393/
> -----------------------------------------------------------
>
> (Updated Feb. 2, 2015, 8:59 p.m.)
>
>
> Review request for KDE Frameworks and Martin Klapetek.
>
>
> Bugs: 342752
> https://bugs.kde.org/show_bug.cgi?id=342752
>
>
> Repository: knotifications
>
>
> Description
> -------
>
> - Follow code would crash with current code, because notificationQueue may contain dangling pointer to KNotification.
>
> #include <QApplication>
> #include <KNotification>
>
> int main(int argc, char* argv[]) {
> QApplication app(argc,argv);
>
> do {
> KNotification a("NewMessage");
> a.setComponentName("kwrited"); // just a random component for test
> a.sendEvent();
> } while(0);
>
> app.exec();
>
> return 0;
> }
>
> This is fixed by remove item from queue in ::close.
>
> - 342752 might happen because galagoNotifications may contain dangling pointer.
> This is fixed by using QPointer in galagoNotifications (instead of in ::close, because it will initiate a dbus call and others may be still willing to wait for finished signal).
>
> If KNotification is already deleted, don't call other related functions on this KNotification.
>
> - watcher is safer to call deleteLater on watcher first.
>
>
> Diffs
> -----
>
> src/notifybypopup.cpp 95937fc
>
> Diff: https://git.reviewboard.kde.org/r/122393/diff/
>
>
> Testing
> -------
>
> Above code doesn't crash anymore.
>
>
> Thanks,
>
> Xuetian Weng
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20150202/c899db99/attachment.html>
More information about the Kde-frameworks-devel
mailing list