From 1c883ba767559953f6383c5f850aa4fe2cf21047 Mon Sep 17 00:00:00 2001
From: Stephane Del Pino <stephane.delpino44@gmail.com>
Date: Sat, 2 Oct 2021 22:22:19 +0200
Subject: [PATCH] Fix CastArray copy_to in the case of empty arrays

---
 src/utils/CastArray.hpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/utils/CastArray.hpp b/src/utils/CastArray.hpp
index 71bfc246f..07c696428 100644
--- a/src/utils/CastArray.hpp
+++ b/src/utils/CastArray.hpp
@@ -40,8 +40,9 @@ class [[nodiscard]] CastArray
     static_assert(not std::is_const_v<ImageCastDataType>);
 
     Assert(source_array.size() == image_array.size());
-
-    std::copy(source_array.m_values, source_array.m_values + source_array.size(), &image_array[0]);
+    if (source_array.size() > 0) {
+      std::copy(source_array.m_values, source_array.m_values + source_array.size(), &image_array[0]);
+    }
   }
 
   PUGS_INLINE
-- 
GitLab