Fix null errors

This commit is contained in:
Ethan Chiu
2020-07-08 12:33:22 -04:00
parent 7c57d41b3a
commit 35879fc3b1

View File

@@ -74,7 +74,8 @@ namespace GitHub.Runner.Worker
var fileId = templateContext.GetFileId(fileRelativePath); var fileId = templateContext.GetFileId(fileRelativePath);
// Add this file to the FileTable in executionContext if it hasn't been added already // Add this file to the FileTable in executionContext if it hasn't been added already
if (fileId > executionContext.FileTable.Count) // we use > since fileID is zero indexed
if (fileId > executionContext.FileTable?.Count)
{ {
executionContext.FileTable.Add(fileRelativePath); executionContext.FileTable.Add(fileRelativePath);
} }
@@ -297,7 +298,7 @@ namespace GitHub.Runner.Worker
} }
// Add the file table from the Execution Context // Add the file table from the Execution Context
if (executionContext.FileTable.Count > 0) if (executionContext.FileTable?.Count > 0)
{ {
for (var i = 0; i < executionContext.FileTable.Count; i++) for (var i = 0; i < executionContext.FileTable.Count; i++)
{ {