0
0
mirror of https://github.com/assimp/assimp.git synced 2026-01-18 17:11:20 +01:00

fuzz: Fix memory leak in ForceFormat helper (#6435)

The ForceFormat function unregisters importers from the Importer
but doesn't delete them, causing memory leaks detected by ASan
during OSS-Fuzz check_build.

When UnregisterLoader is called, the importer is removed from the
internal list but the memory is not freed. Since the Importer
originally allocated these objects and we're removing them from
its management, we must delete them explicitly.

Also include BaseImporter.h to ensure complete type information
is available for proper deletion.

This fixes OSS-Fuzz check_build failures for all format-specific
fuzzers (obj, gltf, glb, fbx, collada, stl).
This commit is contained in:
LP
2026-01-09 18:02:21 +08:00
committed by GitHub
parent 17318b02cf
commit 522c703bb9

View File

@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <assimp/Importer.hpp>
#include <assimp/BaseImporter.h>
#include <assimp/importerdesc.h>
#include <cstring>
#include <vector>
@@ -97,6 +98,7 @@ inline bool ForceFormat(Assimp::Importer& importer, const char* targetExtension)
for (auto* imp : toRemove) {
importer.UnregisterLoader(imp);
delete imp; // Free the unregistered importer to prevent memory leaks
}
return found;