IVGCVSW-7901 Fix unsafe Usages of Memcpy in Armnn

* Updated usages of Memcpy to use proper checks for null instead of asserts
* Added error checking in places where none existed

Signed-off-by: David Monahan <david.monahan@arm.com>
Change-Id: I9529acd966466ba281f88918be2ec372a756e183
diff --git a/src/backends/reference/RefTensorHandle.cpp b/src/backends/reference/RefTensorHandle.cpp
index cce992c..07f497c 100644
--- a/src/backends/reference/RefTensorHandle.cpp
+++ b/src/backends/reference/RefTensorHandle.cpp
@@ -101,16 +101,30 @@
 
 void RefTensorHandle::CopyOutTo(void* dest) const
 {
-    const void *src = GetPointer();
-    ARMNN_ASSERT(src);
-    memcpy(dest, src, m_TensorInfo.GetNumBytes());
+    const void* src = GetPointer();
+    if (src == nullptr)
+    {
+        throw NullPointerException("TensorHandle::CopyOutTo called with a null src pointer");
+    }
+    if (dest == nullptr)
+    {
+        throw NullPointerException("TensorHandle::CopyOutTo called with a null dest pointer");
+    }
+    memcpy(dest, src, GetTensorInfo().GetNumBytes());
 }
 
 void RefTensorHandle::CopyInFrom(const void* src)
 {
-    void *dest = GetPointer();
-    ARMNN_ASSERT(dest);
-    memcpy(dest, src, m_TensorInfo.GetNumBytes());
+    void* dest = GetPointer();
+    if (dest == nullptr)
+    {
+        throw NullPointerException("RefTensorHandle::CopyInFrom called with a null dest pointer");
+    }
+    if (src == nullptr)
+    {
+        throw NullPointerException("RefTensorHandle::CopyInFrom called with a null src pointer");
+    }
+    memcpy(dest, src, GetTensorInfo().GetNumBytes());
 }
 
 MemorySourceFlags RefTensorHandle::GetImportFlags() const