Skip to content

Commit

Permalink
Add safety around executable wrapper creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadareski committed May 15, 2024
1 parent aa690ab commit 3e75d9f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions BinaryObjectScanner/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using BinaryObjectScanner.Interfaces;
using BinaryObjectScanner.Utilities;
using SabreTools.IO.Extensions;
using SabreTools.Serialization.Interfaces;
using SabreTools.Serialization.Wrappers;
using static BinaryObjectScanner.Utilities.Dictionary;

Expand Down Expand Up @@ -425,9 +426,18 @@ public Scanner(bool scanArchives, bool scanContents, bool scanGameEngines, bool
#endif
{
// Try to create a wrapper for the proper executable type
var wrapper = WrapperFactory.CreateExecutableWrapper(stream);
if (wrapper == null)
IWrapper? wrapper;
try
{
wrapper = WrapperFactory.CreateExecutableWrapper(stream);
if (wrapper == null)
return null;
}
catch (Exception ex)
{
if (IncludeDebug) Console.WriteLine(ex);
return null;
}

// Create the output dictionary
#if NET20 || NET35
Expand Down

0 comments on commit 3e75d9f

Please sign in to comment.