Fix #95411: Collada export crashes if temporary file is not accessible #118958

Merged
Philipp Oeser merged 4 commits from lichtwerk/blender:95411_b into blender-v4.1-release 2024-03-05 13:14:57 +01:00
1 changed files with 9 additions and 0 deletions
Showing only changes of commit 2c6a1ffc6c - Show all commits

View File

@ -171,6 +171,15 @@ int DocumentExporter::exportCurrentScene()
clear_global_id_map();
COLLADABU::NativeString native_filename = make_temp_filepath(nullptr, ".dae");
/* Avoid crash if temp file cannot be written to. */
if (BLI_access(native_filename.c_str(), W_OK) != 0) {
fprintf(stderr,
"Collada: Temp file (%s) cannot be written to. No Objects will be exported.\n",
native_filename.c_str());
return 1;
lichtwerk marked this conversation as resolved Outdated

Files can fail to be created for many reasons, this only addresses not having permissions.

It would be better to catch the COLLADASW::StreamWriterException.

Files can fail to be created for many reasons, this only addresses not having permissions. It would be better to catch the `COLLADASW::StreamWriterException`.
}
COLLADASW::StreamWriter *writer = new COLLADASW::StreamWriter(native_filename);
/* open <collada> */