Review Request 122393: Fix dangling pointer and possible memory leak in knotifications

Xuetian Weng wengxt at gmail.com
Mon Feb 2 21:35:44 UTC 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122393/
-----------------------------------------------------------

(Updated Feb. 2, 2015, 9:35 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 (updated)
-----

  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/d031a108/attachment.html>


More information about the Kde-frameworks-devel mailing list