diff --git a/irr/src/CGLTFMeshFileLoader.cpp b/irr/src/CGLTFMeshFileLoader.cpp index 6e7cd3ee6..537911e88 100644 --- a/irr/src/CGLTFMeshFileLoader.cpp +++ b/irr/src/CGLTFMeshFileLoader.cpp @@ -650,8 +650,10 @@ void SelfType::MeshExtractor::copyTCoords( std::optional SelfType::tryParseGLTF(io::IReadFile* file) { auto size = file->getSize(); + if (size < 0) // this can happen if `ftell` fails + return std::nullopt; auto buf = std::make_unique(size + 1); - if (file->read(buf.get(), size) != size) + if (file->read(buf.get(), size) != static_cast(size)) return std::nullopt; // We probably don't need this, but add it just to be sure. buf[size] = '\0';