@@ -850,47 +850,50 @@ public PortableExecutable(Models.PortableExecutable.Executable? model, Stream? d
850850 if ( string . IsNullOrEmpty ( key ) )
851851 return null ;
852852
853- // If we have the value cached
854- if ( _versionInfoStrings . ContainsKey ( key ) )
855- return _versionInfoStrings [ key ] ;
853+ lock ( _sourceDataLock )
854+ {
855+ // If we have the value cached
856+ if ( _versionInfoStrings . ContainsKey ( key ) )
857+ return _versionInfoStrings [ key ] ;
856858
857- // Ensure that we have the resource data cached
858- if ( ResourceData == null )
859- return null ;
859+ // Ensure that we have the resource data cached
860+ if ( ResourceData == null )
861+ return null ;
860862
861- // If we don't have string version info in this executable
862- var stringTable = _versionInfo ? . StringFileInfo ? . Children ;
863- if ( stringTable == null || stringTable . Length == 0 )
864- return null ;
863+ // If we don't have string version info in this executable
864+ var stringTable = _versionInfo ? . StringFileInfo ? . Children ;
865+ if ( stringTable == null || stringTable . Length == 0 )
866+ return null ;
865867
866- // Try to find a key that matches
868+ // Try to find a key that matches
867869#if NET20
868- Models . PortableExecutable . StringData ? match = null ;
869- foreach ( var st in stringTable )
870- {
871- if ( st ? . Children == null )
872- continue ;
873-
874- // Return the match if found
875- match = Array . Find ( st . Children , sd => sd != null && key . Equals ( sd . Key , StringComparison . OrdinalIgnoreCase ) ) ;
876- if ( match != null )
870+ Models . PortableExecutable . StringData ? match = null ;
871+ foreach ( var st in stringTable )
877872 {
878- _versionInfoStrings [ key ] = match . Value ? . TrimEnd ( '\0 ' ) ;
879- return _versionInfoStrings [ key ] ;
873+ if ( st ? . Children == null )
874+ continue ;
875+
876+ // Return the match if found
877+ match = Array . Find ( st . Children , sd => sd != null && key . Equals ( sd . Key , StringComparison . OrdinalIgnoreCase ) ) ;
878+ if ( match != null )
879+ {
880+ _versionInfoStrings [ key ] = match . Value ? . TrimEnd ( '\0 ' ) ;
881+ return _versionInfoStrings [ key ] ;
882+ }
880883 }
881- }
882884
883- _versionInfoStrings [ key ] = null ;
884- return _versionInfoStrings [ key ] ;
885+ _versionInfoStrings [ key ] = null ;
886+ return _versionInfoStrings [ key ] ;
885887#else
886- var match = stringTable
887- . SelectMany ( st => st ? . Children ?? [ ] )
888- . FirstOrDefault ( sd => sd != null && key . Equals ( sd . Key , StringComparison . OrdinalIgnoreCase ) ) ;
888+ var match = stringTable
889+ . SelectMany ( st => st ? . Children ?? [ ] )
890+ . FirstOrDefault ( sd => sd != null && key . Equals ( sd . Key , StringComparison . OrdinalIgnoreCase ) ) ;
889891
890- // Return either the match or null
891- _versionInfoStrings [ key ] = match ? . Value ? . TrimEnd ( '\0 ' ) ;
892- return _versionInfoStrings [ key ] ;
892+ // Return either the match or null
893+ _versionInfoStrings [ key ] = match ? . Value ? . TrimEnd ( '\0 ' ) ;
894+ return _versionInfoStrings [ key ] ;
893895#endif
896+ }
894897 }
895898
896899 /// <summary>
0 commit comments