diff --git a/tiny_gltf_loader.h b/tiny_gltf_loader.h index 7067cdf..9cb3a46 100644 --- a/tiny_gltf_loader.h +++ b/tiny_gltf_loader.h @@ -2286,6 +2286,13 @@ bool TinyGLTFLoader::LoadASCIIFromFile(Scene *scene, std::string *err, size_t sz = static_cast(f.tellg()); std::vector buf(sz); + if (sz == 0) { + if (err) { + (*err) = "Empty file."; + } + return false; + } + f.seekg(0, f.beg); f.read(&buf.at(0), static_cast(sz)); f.close();