Make safe conversion from uint32_t to streamsize 65/289465/1
authorseungho baek <sbsh.baek@samsung.com>
Wed, 8 Mar 2023 06:23:52 +0000 (15:23 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 8 Mar 2023 06:25:11 +0000 (15:25 +0900)
Change-Id: I575d11e330723fe53528a72b3abfaccef4c39523
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
dali-scene3d/internal/loader/glb-loader-impl.cpp

index 4ab9f70922b168ce1263051a24dd4e9f2cfdcb35..deaa91e9fa6b82bddb46063a6450aa42f7a5b539 100644 (file)
@@ -85,7 +85,7 @@ bool GlbLoaderImpl::LoadModel(const std::string& url, Dali::Scene3D::Loader::Loa
 
   std::vector<uint8_t> jsonChunkData;
   jsonChunkData.resize(jsonChunkHeader.chunkLength);
-  stream.read(reinterpret_cast<char*>(&jsonChunkData[0]), jsonChunkHeader.chunkLength);
+  stream.read(reinterpret_cast<char*>(&jsonChunkData[0]), static_cast<std::streamsize>(static_cast<size_t>(jsonChunkHeader.chunkLength)));
   std::string gltfText(jsonChunkData.begin(), jsonChunkData.end());
 
   uint32_t             binaryChunkOffset = sizeof(GlbHeader) + sizeof(ChunkHeader) + jsonChunkHeader.chunkLength;
@@ -102,7 +102,7 @@ bool GlbLoaderImpl::LoadModel(const std::string& url, Dali::Scene3D::Loader::Loa
     }
 
     binaryChunkData.resize(binaryChunkHeader.chunkLength);
-    stream.read(reinterpret_cast<char*>(&binaryChunkData[0]), binaryChunkHeader.chunkLength);
+    stream.read(reinterpret_cast<char*>(&binaryChunkData[0]), static_cast<std::streamsize>(static_cast<size_t>(binaryChunkHeader.chunkLength)));
   }
 
   json::unique_ptr root(json_parse(gltfText.c_str(), gltfText.size()));