Permalink
Browse files

audqt: Use deleteLater() to prevent use-after-free in Qt event handli…

…ng. Closes: #828.
  • Loading branch information...
jlindgren90 committed Sep 20, 2018
1 parent 1528e78 commit 1d34f6799b8f5910fc6863ae96afd5ab035e830f
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/libaudqt/infopopup-qt.cc
@@ -176,7 +176,9 @@ static InfoPopup * s_infopopup;
static void infopopup_show (const String & filename, const Tuple & tuple)
{
delete s_infopopup;
if (s_infopopup)
s_infopopup->deleteLater ();
s_infopopup = new InfoPopup (filename, tuple);
QObject::connect (s_infopopup, & QObject::destroyed, [] () {
@@ -206,7 +208,11 @@ EXPORT void infopopup_show_current ()
EXPORT void infopopup_hide ()
{
delete s_infopopup;
/* This function can be called from an enter/leave event, and Qt does not
* like widgets being deleted from such events. This is debatably a bug in
* Qt, but deleteLater() is an effective workaround. */
if (s_infopopup)
s_infopopup->deleteLater ();
}
} // namespace audqt

0 comments on commit 1d34f67

Please sign in to comment.