Procházet zdrojové kódy

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).
LP před 6 dny
rodič
revize
522c703bb9
1 změnil soubory, kde provedl 2 přidání a 0 odebrání
  1. 2 0
      fuzz/fuzzer_common.h

+ 2 - 0
fuzz/fuzzer_common.h

@@ -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;