From 60fb268d9a408466fda9c72d9c23ff46ebe533a2 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 15 May 2024 20:56:25 +0200 Subject: [PATCH] Fix UBSAN error "member call does not point to an object of type" runtime error: member call on address XXX which does not point to an object of type 'Allocator' XXX: note: object is of type 'SpyingAllocator' This is due to the fact that some of the compilation units have different library settings, so a different namespace, and therefore a different `Allocator` class. --- extras/tests/Helpers/Allocators.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extras/tests/Helpers/Allocators.hpp b/extras/tests/Helpers/Allocators.hpp index 5df98ed4..6877eaf1 100644 --- a/extras/tests/Helpers/Allocators.hpp +++ b/extras/tests/Helpers/Allocators.hpp @@ -10,6 +10,8 @@ #include +namespace { + struct FailingAllocator : ArduinoJson::Allocator { static FailingAllocator* instance() { static FailingAllocator allocator; @@ -260,6 +262,7 @@ class TimebombAllocator : public ArduinoJson::Allocator { size_t countdown_ = 0; Allocator* upstream_; }; +} // namespace inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) { return sizeof(ArduinoJson::detail::VariantPool) * n;