summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/KM_platform.h11
-rwxr-xr-xsrc/MXFTypes.cpp4
2 files changed, 12 insertions, 3 deletions
diff --git a/src/KM_platform.h b/src/KM_platform.h
index defcd8a..3e50e54 100644
--- a/src/KM_platform.h
+++ b/src/KM_platform.h
@@ -64,6 +64,7 @@ typedef long long i64_t;
# endif // KM_WIN32
# include <stdio.h>
+# include <string.h>
# include <assert.h>
# include <stdlib.h>
# include <limits.h>
@@ -135,11 +136,17 @@ namespace Kumu
// read an integer from byte-structured storage
template<class T>
- inline T cp2i(const byte_t* p) { return *(T*)p; }
+ inline T cp2i(const byte_t* p) {
+ T value;
+ memcpy(&value, p, sizeof(T));
+ return value;
+ }
// write an integer to byte-structured storage
template<class T>
- inline void i2p(T i, byte_t* p) { *(T*)p = i; }
+ inline void i2p(T i, byte_t* p) {
+ memcpy(p, &i, sizeof(T));
+ }
# ifdef KM_BIG_ENDIAN
diff --git a/src/MXFTypes.cpp b/src/MXFTypes.cpp
index 72338bb..412f336 100755
--- a/src/MXFTypes.cpp
+++ b/src/MXFTypes.cpp
@@ -286,7 +286,9 @@ ASDCP::MXF::UTF16String::Unarchive(Kumu::MemIOReader* Reader)
for ( ui32_t i = 0; i < length; i++ )
{
- int count = wcrtomb(mb_buf, KM_i16_BE(p[i]), &ps);
+ ui16_t pi;
+ memcpy(&pi, &p[i], sizeof(ui16_t));
+ int count = wcrtomb(mb_buf, KM_i16_BE(pi), &ps);
if ( count == -1 )
{