From 53692fc9c552d942bb8b69b9d6b9ff0437ab5768 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 2 Apr 2025 09:18:36 +0200 Subject: [PATCH] tst_QMainWindow: fix unit'ed value in AddDockWidget The constructors didn't initialize all fields, leading the compiler-generated move contructor to read invalid enum values: Says UBSan: tst_qmainwindow.cpp:1645:8: runtime error: load of value 32675, which is not a valid value for type 'Orientation' #0 0x55b1bd283e2e in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645 [...] tst_qmainwindow.cpp:1645:8: runtime error: load of value 72, which is not a valid value for type 'DockWidgetArea' #0 0x55b1bd284024 in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645 [...] (ubsan does not direct uninitialized memory accesses directly). Fix by vale-initalizing the two members. This is the most natural initialization for these members: Given that the test passed even with random data before, 0 is surely good enough. Amends the start of the public history. Pick-to: 6.8 6.5 5.15 Change-Id: I6fc0b2f79679fd0f69024066c1e66b4434a5ebe6 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit af71de2036728091b432d7b4284368188961b680) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index bf0f58587a4..09d3eb1e8df 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -1657,8 +1657,8 @@ struct AddDockWidget QString name; Mode mode; - Qt::Orientation o; - Qt::DockWidgetArea a; + Qt::Orientation o = {}; + Qt::DockWidgetArea a = {}; QString other; void apply(QMainWindow *mw) const;