Skip to content

Commit

Permalink
WE_HAVE_CRITICAL_ERROR_METHOD nullptr check
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jul 23, 2024
1 parent c562c65 commit 51ee7d1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/include/rusefi/arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ constexpr size_t size(const T(&)[N]) {
// Zero the passed object
template <typename T>
constexpr void clear(T* obj) {
#ifdef WE_HAVE_CRITICAL_ERROR_METHOD
if (obj == nullptr) {
criticalError("clear nullptr");
return;
}
#endif // WE_HAVE_CRITICAL_ERROR_METHOD
// The cast to void* is to prevent errors like:
// clearing an object of non-trivial type 'struct persistent_config_s'; use assignment or value-initialization instead
// This is technically wrong, but we know config objects only ever actually
Expand Down

0 comments on commit 51ee7d1

Please sign in to comment.