Skip to content

Commit 522c703

Browse files
authored
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).
1 parent 17318b0 commit 522c703

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fuzz/fuzzer_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4141
#pragma once
4242

4343
#include <assimp/Importer.hpp>
44+
#include <assimp/BaseImporter.h>
4445
#include <assimp/importerdesc.h>
4546
#include <cstring>
4647
#include <vector>
@@ -97,6 +98,7 @@ inline bool ForceFormat(Assimp::Importer& importer, const char* targetExtension)
9798

9899
for (auto* imp : toRemove) {
99100
importer.UnregisterLoader(imp);
101+
delete imp; // Free the unregistered importer to prevent memory leaks
100102
}
101103

102104
return found;

0 commit comments

Comments
 (0)