//\r
Section = FirstSection;\r
for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {\r
+ //\r
+ // Read the section\r
+ //\r
+ Size = (UINTN) Section->Misc.VirtualSize;\r
+ if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
+ Size = (UINTN) Section->SizeOfRawData;\r
+ }\r
+\r
//\r
// Compute sections address\r
//\r
);\r
\r
//\r
- // If the base start or end address resolved to 0, then fail.\r
+ // If the size of the section is non-zero and the base address or end address resolved to 0, then fail.\r
//\r
- if ((Base == NULL) || (End == NULL)) {\r
+ if ((Size > 0) && ((Base == NULL) || (End == NULL))) {\r
ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;\r
return RETURN_LOAD_ERROR;\r
}\r
MaxEnd = End;\r
}\r
\r
- //\r
- // Read the section\r
- //\r
- Size = (UINTN) Section->Misc.VirtualSize;\r
- if ((Size == 0) || (Size > Section->SizeOfRawData)) {\r
- Size = (UINTN) Section->SizeOfRawData;\r
- }\r
-\r
if (Section->SizeOfRawData > 0) {\r
if (!(ImageContext->IsTeImage)) {\r
Status = ImageContext->ImageRead (\r