FBXExporter: Fix stack-use-after-scope in WriteObjects (#6472)
The FBX exporter was unconditionally dereferencing a map iterator (`tp_elem`) even when the key was not found (i.e., `tp_elem == tpath_by_image.end()`). This resulted in a stack-use-after-scope error when accessing `tp_elem->second` to populate "FileName" and "RelativeFilename" nodes, as dereferencing the end iterator of the map accessed invalid stack memory (the map's sentinel). The code already correctly initialized a local `tfile_path` variable based on whether the iterator was valid. This patch updates the `AddChild` calls to use `tfile_path` instead of dereferencing the potentially invalid iterator. Fixes: https://issues.oss-fuzz.com/issues/465494996 Co-authored-by: CodeMender <codemender-patching@google.com> Co-authored-by: Kim Kulling <kimkulling@users.noreply.github.com>
This commit is contained in:
@@ -1766,8 +1766,8 @@ void FBXExporter::WriteObjects () {
|
||||
// can't easily determine which texture path will be correct,
|
||||
// so just store what we have in every field.
|
||||
// these being incorrect is a common problem with FBX anyway.
|
||||
tnode.AddChild("FileName", tp_elem->second);
|
||||
tnode.AddChild("RelativeFilename", tp_elem->second);
|
||||
tnode.AddChild("FileName", tfile_path);
|
||||
tnode.AddChild("RelativeFilename", tfile_path);
|
||||
tnode.AddChild("ModelUVTranslation", double(0.0), double(0.0));
|
||||
tnode.AddChild("ModelUVScaling", double(1.0), double(1.0));
|
||||
tnode.AddChild("Texture_Alpha_Source", "None");
|
||||
|
||||
Reference in New Issue
Block a user