From 720dab7ad0f77b739a12f0e3e7e7178ea16c2e64 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 14 Mar 2017 13:51:27 +0100 Subject: Protect Lookup usage against cross-compilation word size differences The offsets we're taking from Lookup in the code generator are always zero, but with static assertions we can ensure that they stay that way. Task-number: QTBUG-58666 Change-Id: I91e047d2101ba33e36aaada4a5adc75e20fea7d8 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4lookup_p.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/qml/jsruntime/qv4lookup_p.h') diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index c5ee92fedd..2ffb43cce9 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -141,6 +141,13 @@ struct Lookup { }; +Q_STATIC_ASSERT(std::is_standard_layout::value); +// Ensure that these offsets are always at this point to keep generated code compatible +// across 32-bit and 64-bit (matters when cross-compiling). +Q_STATIC_ASSERT(offsetof(Lookup, indexedGetter) == 0); +Q_STATIC_ASSERT(offsetof(Lookup, getter) == 0); +Q_STATIC_ASSERT(offsetof(Lookup, engine) == offsetof(Lookup, getter) + QT_POINTER_SIZE); + } QT_END_NAMESPACE -- cgit v1.2.3