Преглед изворни кода

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.
Benoit Blanchon пре 1 година
родитељ
комит
60fb268d9a
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      extras/tests/Helpers/Allocators.hpp

+ 3 - 0
extras/tests/Helpers/Allocators.hpp

@@ -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;