diff --git a/libutils/include/utils/Flattenable.h b/libutils/include/utils/Flattenable.h index 22b811a14..070c71026 100644 --- a/libutils/include/utils/Flattenable.h +++ b/libutils/include/utils/Flattenable.h @@ -189,11 +189,11 @@ public: } inline status_t flatten(void* buffer, size_t size) const { if (size < sizeof(T)) return NO_MEMORY; - *reinterpret_cast(buffer) = *static_cast(this); + memcpy(buffer, static_cast(this), sizeof(T)); return NO_ERROR; } inline status_t unflatten(void const* buffer, size_t) { - *static_cast(this) = *reinterpret_cast(buffer); + memcpy(static_cast(this), buffer, sizeof(T)); return NO_ERROR; } };