From 10ed5f98b993edfde5042b79df4320b22955477f Mon Sep 17 00:00:00 2001 From: Bjorn Terelius Date: Wed, 11 Aug 2021 10:06:32 +0200 Subject: [PATCH] Increase sigslot internal pointer representation to 24 bytes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:12836 Change-Id: Ic3bfa7fd637d27d580e6921afadb364bbba2fe03 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228425 Reviewed-by: Mirko Bonadei Commit-Queue: Björn Terelius Cr-Commit-Position: refs/heads/master@{#34717} --- rtc_base/third_party/sigslot/sigslot.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rtc_base/third_party/sigslot/sigslot.h b/rtc_base/third_party/sigslot/sigslot.h index 6dc62c5a77..a4de0e6603 100644 --- a/rtc_base/third_party/sigslot/sigslot.h +++ b/rtc_base/third_party/sigslot/sigslot.h @@ -290,9 +290,13 @@ class _opaque_connection { emit_t pemit; has_slots_interface* pdest; - // Pointers to member functions may be up to 16 bytes for virtual classes, - // so make sure we have enough space to store it. + // Pointers to member functions may be up to 16 bytes (24 bytes for MSVC) + // for virtual classes, so make sure we have enough space to store it. +#if defined(_MSC_VER) && !defined(__clang__) + unsigned char pmethod[24]; +#else unsigned char pmethod[16]; +#endif public: template @@ -332,6 +336,8 @@ class _opaque_connection { static void emitter(const _opaque_connection* self, Args... args) { typedef void (DestT::*pm_t)(Args...); pm_t pm; + static_assert(sizeof(pm_t) <= sizeof(pmethod), + "Size of slot function pointer too large."); std::memcpy(&pm, self->pmethod, sizeof(pm_t)); (static_cast(self->pdest)->*(pm))(args...); }