Allow destruction of QWinEventNotifier in its signal

Avoid use-after-free issue in QProcess.

Fixes: QTBUG-96285
Fixes: QTBUG-96359
Pick-to: 6.2 6.1
Change-Id: I953d7a8ecaf301ec3a27db37e13748f905c3d097
Reviewed-by: Christoph Cullmann <cullmann@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
Alex Trotsenko 2021-09-09 17:14:07 +03:00
parent a265333133
commit 4e0082a9ca

View File

@ -41,6 +41,7 @@
#include "qcoreapplication.h"
#include "qthread.h"
#include <QPointer>
QT_BEGIN_NAMESPACE
@ -238,9 +239,10 @@ bool QWinEventNotifier::event(QEvent * e)
// when the callback is queued.
d->registered = false;
QPointer<QWinEventNotifier> alive(this);
emit activated(d->handleToEvent, QPrivateSignal());
if (d->enabled && !d->registered) {
if (alive && d->enabled && !d->registered) {
SetThreadpoolWait(d->waitObject, d->handleToEvent, NULL);
d->registered = true;
}