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

same to c8cc973888e6d1148264f619c85fea93ca2f1b7c

src/savers/tvg/tvgTvgSaver.cpp

index e882bc2..2d37319 100644 (file)
@@ -164,15 +164,15 @@ bool TvgSaver::saveEncoding(const std::string& path)
     uncompressed += TVG_HEADER_RESERVED_LENGTH;
 
     //Uncompressed Size
-    *reinterpret_cast<TvgBinCounter*>(uncompressed) = uncompressedSize;
+    memcpy(uncompressed, &uncompressedSize, TVG_HEADER_UNCOMPRESSED_SIZE);
     uncompressed += TVG_HEADER_UNCOMPRESSED_SIZE;
 
     //Comprssed Size
-    *reinterpret_cast<TvgBinCounter*>(uncompressed) = compressedSize;
+    memcpy(uncompressed, &compressedSize, TVG_HEADER_COMPRESSED_SIZE);
     uncompressed += TVG_HEADER_COMPRESSED_SIZE;
 
     //Compressed Size Bits
-    *reinterpret_cast<TvgBinCounter*>(uncompressed) = compressedSizeBits;
+    memcpy(uncompressed, &compressedSizeBits, TVG_HEADER_COMPRESSED_SIZE_BITS);
 
     //Good optimization, flush to file.
     auto fp = fopen(path.c_str(), "w+");