Skip to content

Commit

Permalink
TS-31191 fix nullpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
jveihelmann committed Dec 8, 2023
1 parent bae15bb commit 92c822f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ private void SearchForEmbeddedUploadTargets()
foreach ((_, string path) in this.LoadedAssemblies)
{
Assembly assembly = LoadAssemblyFromPath(path);
IEnumerable<TypeInfo> definedTypes = assembly.DefinedTypes;
if(assembly == null || definedTypes == null)
if (assembly == null || assembly.DefinedTypes == null)
{
continue;
}
TypeInfo teamscaleResourceType = definedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null;
TypeInfo teamscaleResourceType = assembly.DefinedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null;
if (teamscaleResourceType == null)
{
continue;
Expand Down Expand Up @@ -138,16 +137,20 @@ private Assembly LoadAssemblyFromPath(string path)
{
return null;
}
Assembly assembly = null;
Assembly assembly;
try
{
assembly = Assembly.LoadFrom(path);
// Check that defined types can actually be loaded (this is implicetly a null check as well)
IEnumerable<TypeInfo> definedTypes = assembly.DefinedTypes;
// Check that defined types can actually be loaded
if (assembly == null)
{
return null;
}
IEnumerable<TypeInfo> ignored = assembly.DefinedTypes;
}
catch (Exception e)
{
logger.Warn("Could not load {assembly}. Skipping upload resource discovery. {e}", path, e);
logger.Debug("Could not load {assembly}. Skipping upload resource discovery. {e}", path, e);
return null;
}
return assembly;
Expand Down

0 comments on commit 92c822f

Please sign in to comment.