Skip to content

Commit

Permalink
MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty
Browse files Browse the repository at this point in the history
The original code will assert when dealing with those empty FVs.
The fix is used to solve this bug.

Cc: Chao Zhang <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Chao Zhang <[email protected]>
  • Loading branch information
ftian1 committed Aug 3, 2016
1 parent 846ea5f commit ebd2be6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,10 @@ FvSimpleFileSystemOpen (
InitializeListHead (&NewFile->Link);
InsertHeadList (&Instance->FileHead, &NewFile->Link);

NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
NewFile->DirReadNext = NULL;
if (!IsListEmpty (&Instance->FileInfoHead)) {
NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}

*NewHandle = &NewFile->FileProtocol;
return EFI_SUCCESS;
Expand Down Expand Up @@ -821,7 +824,9 @@ FvSimpleFileSystemSetPosition (
//
// Reset directory position to first entry
//
File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
if (File->DirReadNext) {
File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}
} else if (Position == 0xFFFFFFFFFFFFFFFFull) {
File->Position = File->FvFileInfo->FileInfo.FileSize;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ FvSimpleFileSystemOpenVolume (
}
}

Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
Instance->Root->DirReadNext = NULL;
if (!IsListEmpty (&Instance->FileInfoHead)) {
Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}

*RootFile = &Instance->Root->FileProtocol;
return Status;
}
Expand Down

0 comments on commit ebd2be6

Please sign in to comment.