Skip to content

Commit b8370c7

Browse files
committed
Dispose loaded file ASAP
1 parent 5c69e7e commit b8370c7

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Lib/Sources/BinaryFileLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public static Firmware Load( Stream stream )
4545
*
4646
* @param [in] filePath Path to the file containing the firmware
4747
*/
48-
public static Task<Firmware> LoadAsync( string filePath )
48+
public static async Task<Firmware> LoadAsync( string filePath )
4949
{
50-
var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
50+
using var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
5151

52-
return LoadAsync( fileStream );
52+
return await LoadAsync( fileStream );
5353
}
5454

5555
/**

Lib/Sources/IntelFileLoader.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public static Firmware Load( Stream stream )
4444
*
4545
* @param [in] filePath Path to the file containing the firmware
4646
*/
47-
public static Task<Firmware> LoadAsync( string filePath )
47+
public static async Task<Firmware> LoadAsync( string filePath )
4848
{
49-
var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
50-
51-
return LoadAsync( fileStream );
49+
using var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
50+
return await LoadAsync( fileStream );
5251
}
5352

5453
/**

Lib/Sources/MotorolaFileLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public static Firmware Load( Stream stream )
4444
*
4545
* @param [in] filePath Path to the file containing the firmware
4646
*/
47-
public static Task<Firmware> LoadAsync( string filePath )
47+
public static async Task<Firmware> LoadAsync( string filePath )
4848
{
49-
var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
49+
using var fileStream = new FileStream( filePath, FileMode.Open, FileAccess.Read );
5050

51-
return LoadAsync( fileStream );
51+
return await LoadAsync( fileStream );
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)