summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2020-08-10 21:52:14 +0200
committerDaniel Smith <Daniel.Smith@qt.io>2020-08-24 12:09:35 +0000
commit62f2be9de24bd3760f507e3ceda5b5a1a7f3dbec (patch)
treeaedb85a1c678256b7592b1d247343e7c493340ce /tests
parente1487e8192ca287f29f0f20c616aba972872b7ae (diff)
downloadqtwebchannel-62f2be9de24bd3760f507e3ceda5b5a1a7f3dbec.tar.gz
Fix infinite recursion when wrapping a self-contained object twice
The previous unit test for self-contained objects only wrapped the test object once. After wrapping, a different code path is taken which still exhibited infinite recursion. This patch addresses both the unit test and the infinite recursion. To fix the problem, a boolean in the ObjectInfo struct is toggled to indicate whether the object in question is currently being wrapped. If that is the case, the recursing code path is skipped. [ChangeLog][General] Fixed infinite recursion when dealing with self contained objects. Fixes: QTBUG-84007 Change-Id: Ie0898fb5f28cec91587897835ff937672d60f2a1 Reviewed-by: Kai Koehne <kai.koehne@qt.io> (adapted from commit 0451ef836415c93a6beb68a315a25c6ab27f44fa) Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index a1e824b..181da9e 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -936,6 +936,9 @@ void TestWebChannel::testInfiniteRecursion()
channel.d_func()->publisher->initializeClient(m_dummyTransport);
QJsonObject objectInfo = channel.d_func()->publisher->wrapResult(QVariant::fromValue(&obj), m_dummyTransport).toObject();
+
+ // Wrap the result twice to test for QTBUG-84007. A single result wrap will not trigger all recursion paths.
+ objectInfo = channel.d_func()->publisher->wrapResult(QVariant::fromValue(&obj), m_dummyTransport).toObject();
}
void TestWebChannel::testAsyncObject()