From d99a9ffed96ac26ddada3eeb61c44e6ff8b93895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 11 Dec 2009 10:32:37 +0100 Subject: Avoid crash in QObject::connect() if class has no signals If signalCount was 0, then indexOfSlotRelative would use -1 as the lookup and read unitialized memory in the loop. This would cause a crash in release on Windows. Done-with: Olivier --- src/corelib/kernel/qmetaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index bc1e8dcc..a29f4d2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -497,7 +497,7 @@ static inline int indexOfMethodRelative(const QMetaObject **baseObject, int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) - ? (priv(m->d.data)->signalCount - 1) : 0; + ? (priv(m->d.data)->signalCount) : 0; if (!normalizeStringData) { for (; i >= end; --i) { if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) -- cgit v0.12