Increase sigslot internal pointer representation to 24 bytes.
Bug: webrtc:12836
Change-Id: Ic3bfa7fd637d27d580e6921afadb364bbba2fe03
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228425
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34717}
diff --git a/rtc_base/third_party/sigslot/sigslot.h b/rtc_base/third_party/sigslot/sigslot.h
index 6dc62c5..a4de0e6 100644
--- a/rtc_base/third_party/sigslot/sigslot.h
+++ b/rtc_base/third_party/sigslot/sigslot.h
@@ -290,9 +290,13 @@
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 <typename DestT, typename... Args>
@@ -332,6 +336,8 @@
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<DestT*>(self->pdest)->*(pm))(args...);
}