tvg_loader: resolve sanitizer report.
authorHermet Park <chuneon.park@samsung.com>
Fri, 24 Sep 2021 02:53:46 +0000 (11:53 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 27 Sep 2021 02:21:41 +0000 (11:21 +0900)
"runtime error: load of misaligned address 0x7fb67895c815 for type 'unsigned int', which requires 4 byte alignment"

This is actually not an issue but we can resolve it with an easy workaround,
since we don't need to see this report repeatedly.

src/loaders/tvg/tvgTvgLoader.cpp

index 6f3ab0c..d7f3184 100644 (file)
@@ -79,18 +79,18 @@ bool TvgLoader::readHeader()
 
     //5. Compressed Size if any
     if (compressed) {
-        auto p = reinterpret_cast<TvgBinCounter*>(const_cast<char*>(ptr));
+        auto p = ptr;
 
         //TVG_HEADER_UNCOMPRESSED_SIZE
-        uncompressedSize = *static_cast<uint32_t*>(p);
-        ++p;
+        memcpy(&uncompressedSize, p, sizeof(uint32_t));
+        p += SIZE(uint32_t);
 
         //TVG_HEADER_COMPRESSED_SIZE
-        compressedSize = *static_cast<uint32_t*>(p);
-        ++p;
+        memcpy(&compressedSize, p, sizeof(uint32_t));
+        p += SIZE(uint32_t);
 
         //TVG_HEADER_COMPRESSED_SIZE_BITS
-        compressedSizeBits = *static_cast<uint32_t*>(p);
+        memcpy(&compressedSizeBits, p, sizeof(uint32_t));
     }
 
     ptr += TVG_HEADER_COMPRESS_SIZE;