filament
filament copied to clipboard
gltfio: crash when loading invalid content
Describe the bug
createAsset crashes when given content that's valid JSON, but invalid GLTF.
To Reproduce
Engine* engine = Engine::create();
MaterialProvider* materialProvider = createUbershaderProvider(engine, UBERARCHIVE_DEFAULT_DATA, UBERARCHIVE_DEFAULT_SIZE);
ResourceLoader* resourceLoader = new ResourceLoader(ResourceConfiguration{ .engine = engine });
AssetLoader* assetLoader = AssetLoader::create({ engine, materialProvider });
std::string validJsonInvalidGLTF = "{ \"invalid\": \"gltf\" }";
FilamentAsset* asset = assetLoader->createAsset(reinterpret_cast<uint8_t*>(validJsonInvalidGLTF.data()), validJsonInvalidGLTF.size());
With Filament 1.51.8, this program logs "There is no scene in the asset." to console, and then hits an access violation.
Expected behavior
Print an error to console, and createAsset should return nullptr without crashing.
Logs Call stack:
filament_test.exe!std::copy_n<filament::gltfio::FFilamentInstance * *,unsigned __int64,filament::gltfio::FilamentInstance * *>(filament::gltfio::FFilamentInstance * * _First, unsigned __int64 _Count_raw, filament::gltfio::FilamentInstance * * _Dest) Line 4217 C++
filament_test.exe!filament::gltfio::FAssetLoader::createInstancedAsset(const unsigned char * bytes, unsigned int byteCount, filament::gltfio::FilamentInstance * * instances, unsigned __int64 numInstances) Line 369 C++
filament_test.exe!filament::gltfio::FAssetLoader::createAsset(const unsigned char * bytes, unsigned int byteCount) Line 315 C++
filament_test.exe!filament::gltfio::AssetLoader::createAsset(const unsigned char * bytes, unsigned int nbytes) Line 1617 C++
filament_test.exe!main(int argc, char * * argv) Line 22 C++
Desktop (please complete the following information):
- OS: Windows 11
- GPU: Intel Iris Xe
- Backend: Vulkan