summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-09-24 23:39:27 +0900
committerMichele Calgaro <[email protected]>2024-09-24 23:39:27 +0900
commitb6eef6a49ef86a39ef5159ff4b60d5311f492705 (patch)
treebecf38fabe25f1cb36ec04f139a7f1de1ae0bd47
parent08ac5cce693a7634341db8f4da4d729a64b0af46 (diff)
downloadtqt3-b6eef6a49ef86a39ef5159ff4b60d5311f492705.tar.gz
tqt3-b6eef6a49ef86a39ef5159ff4b60d5311f492705.zip
Fix possible SEGV if the sender object list was null and thread support enabled
Commit manually cherry-picked from 8e653076. Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r--src/kernel/qobject.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp
index 7692e9c21..232de39f7 100644
--- a/src/kernel/qobject.cpp
+++ b/src/kernel/qobject.cpp
@@ -1101,20 +1101,20 @@ bool TQObject::event( TQEvent *e )
|| (d->ownThread == TQThread::currentThreadObject()))
#endif // TQT_THREAD_SUPPORT
{
- TQSenderObjectList* sol;
- TQObject* oldSender = 0;
- sol = senderObjects;
+ TQObject *oldSender = nullptr;
+ TQSenderObjectList *sol = senderObjects;
+ if ( sol )
+ {
#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->lock();
+ sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
- if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = metaEvent->sender();
- }
#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->unlock();
+ sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
+ }
TQUObject *o = metaEvent->data();
if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) {
tqt_emit( metaEvent->id(), o );
@@ -1122,25 +1122,31 @@ bool TQObject::event( TQEvent *e )
if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) {
tqt_invoke( metaEvent->id(), o );
}
+ if ( sol )
+ {
#ifdef TQT_THREAD_SUPPORT
- sol->listMutex->lock();
+ sol->listMutex->lock();
#endif // TQT_THREAD_SUPPORT
- if (sol ) {
sol->currentSender = oldSender;
- if ( sol->deref() ) {
+ if ( sol->deref() )
+ {
#ifdef TQT_THREAD_SUPPORT
sol->listMutex->unlock();
#endif // TQT_THREAD_SUPPORT
delete sol;
- sol = NULL;
+ sol = nullptr;
}
}
#ifdef TQT_THREAD_SUPPORT
- if (sol) sol->listMutex->unlock();
+ if (sol)
+ {
+ sol->listMutex->unlock();
+ }
#endif // TQT_THREAD_SUPPORT
}
#ifdef TQT_THREAD_SUPPORT
- else {
+ else
+ {
tqWarning("TQObject: Ignoring metacall event from non-owning thread");
}
#endif // TQT_THREAD_SUPPORT