From df97d415ecb51688602a2fc2955199c06f14585c Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Wed, 2 Oct 2024 13:53:56 -0500 Subject: Fix bug that allowed any pointer to be used as a writing or reading type. --- include/fud_c_file.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/fud_c_file.hpp b/include/fud_c_file.hpp index 0d52e95..3b7d821 100644 --- a/include/fud_c_file.hpp +++ b/include/fud_c_file.hpp @@ -256,6 +256,7 @@ class CFile { template [[nodiscard]] ReadResult read(T& destination, size_t length) { + static_assert(not std::is_pointer_v); auto& self = static_cast(*this); return self.read(destination, length, 0); } @@ -263,6 +264,7 @@ class CFile { template [[nodiscard]] ReadResult read(T& destination, size_t length, size_t offset) { + static_assert(not std::is_pointer_v); auto& self = static_cast(*this); return self.read(&destination, sizeof(destination), length, offset); } @@ -342,6 +344,7 @@ class CFile { template [[nodiscard]] WriteResult write(const T& source) { + static_assert(not std::is_pointer_v); auto& self = static_cast(*this); return self.write(source, sizeof(source), sizeof(source)); } @@ -349,8 +352,9 @@ class CFile { template [[nodiscard]] WriteResult write(const T& source, size_t sourceSize, size_t length) { + static_assert(not std::is_pointer_v); auto& self = static_cast(*this); - auto offsetResult = size(); + auto offsetResult = self.size(); if (offsetResult.isError()) { return WriteResult{0, offsetResult.getError()}; } @@ -360,6 +364,7 @@ class CFile { template [[nodiscard]] WriteResult write(const T& source, size_t sourceSize, size_t length, size_t offset) { + static_assert(not std::is_pointer_v); auto& self = static_cast(*this); return self.write(static_cast(&source), sourceSize, length, offset); } -- cgit v1.2.3