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

Martin Klapetek martin.klapetek at gmail.com
Mon Feb 2 21:05:31 UTC 2015


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


Thanks for looking into this!


src/notifybypopup.cpp
<https://git.reviewboard.kde.org/r/122393/#comment52047>

    ```auto& item``` --> ```auto &item``` (as per the frameworks coding style)



src/notifybypopup.cpp
<https://git.reviewboard.kde.org/r/122393/#comment52048>

    ```KNotification* n``` --> ```KNotification *n``` (as per the frameworks coding style)



src/notifybypopup.cpp
<https://git.reviewboard.kde.org/r/122393/#comment52049>

    Can you explain this change in a bit more detail?


- Martin Klapetek


On Feb. 2, 2015, 9: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, 9: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/81d8a2ac/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list