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.
This commit is contained in:
Benoit Blanchon
2024-05-15 20:56:25 +02:00
parent f1899d3049
commit 60fb268d9a

View File

@ -10,6 +10,8 @@
#include <sstream>
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;