d9af5af MdeModulePkg DxeCore: Fix double free pages on LoadImage failure path

Authored and Committed by Star Zeng 6 years ago
    MdeModulePkg DxeCore: Fix double free pages on LoadImage failure path
    
    https://bugzilla.tianocore.org/show_bug.cgi?id=667
    reported there is double free pages on LoadImage failure path.
    
    CoreLoadPeImage()
    ...
      return EFI_SUCCESS;
    
    Done:
    
      //
      // Free memory.
      //
      if (DstBufAlocated) {
        CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);
      }
    ...
    
    CoreUnloadAndCloseImage()
    ...
      if ((Image->ImageBasePage != 0) && FreePage) {
        CoreFreePages (Image->ImageBasePage, Image->NumberOfPages);
      }
    ...
    
    This patch is to follow the suggestion at
    https://lists.01.org/pipermail/edk2-devel/2017-August/013112.html
    to set Image->ImageContext.ImageAddress and Image->ImageBasePage to 0
    after the free in CoreLoadPeImage().
    
    Cc: Liming Gao <liming.gao@intel.com>
    Cc: Andrew Fish <afish@apple.com>
    Contributed-under: TianoCore Contribution Agreement 1.0
    Signed-off-by: Star Zeng <star.zeng@intel.com>
    Reviewed-by: Liming Gao <liming.gao@intel.com>