MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty

The original code will assert when dealing with those empty FVs.
The fix is used to solve this bug.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
This commit is contained in:
Feng Tian 2016-08-02 16:07:23 +08:00
parent 846ea5f537
commit ebd2be6875
2 changed files with 12 additions and 3 deletions

View File

@ -526,7 +526,10 @@ FvSimpleFileSystemOpen (
InitializeListHead (&NewFile->Link);
InsertHeadList (&Instance->FileHead, &NewFile->Link);
NewFile->DirReadNext = NULL;
if (!IsListEmpty (&Instance->FileInfoHead)) {
NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}
*NewHandle = &NewFile->FileProtocol;
return EFI_SUCCESS;
@ -821,7 +824,9 @@ FvSimpleFileSystemSetPosition (
//
// Reset directory position to first entry
//
if (File->DirReadNext) {
File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}
} else if (Position == 0xFFFFFFFFFFFFFFFFull) {
File->Position = File->FvFileInfo->FileInfo.FileSize;
} else {

View File

@ -223,7 +223,11 @@ FvSimpleFileSystemOpenVolume (
}
}
Instance->Root->DirReadNext = NULL;
if (!IsListEmpty (&Instance->FileInfoHead)) {
Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
}
*RootFile = &Instance->Root->FileProtocol;
return Status;
}