Reviewed-by: Eric Dong <eric.d...@intel.com>

> -----Original Message-----
> From: Bi, Dandan
> Sent: Tuesday, March 01, 2016 10:14 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming; Dong, Eric
> Subject: [patch] MdeModulePkg: FileExplorerLib: Add check when to call 
> FreePool function
> 
> when free up resource allocated for a MenuEntry, there exists
> the case that the DevicePath and DisplayString are NULL,
> so before calling FreePool function, need to check.
> 
> Cc: Liming Gao <liming....@intel.com>
> Cc: Eric Dong <eric.d...@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Dandan Bi <dandan...@intel.com>
> ---
>  MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c 
> b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
> index 9714dbc..98c81db 100644
> --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
> +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
> @@ -300,11 +300,13 @@ LibDestroyMenuEntry (
>    FILE_CONTEXT           *FileContext;
> 
>    FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;
> 
>    if (!FileContext->IsRoot) {
> -    FreePool (FileContext->DevicePath);
> +    if (FileContext->DevicePath != NULL) {
> +      FreePool (FileContext->DevicePath);
> +    }
>    } else {
>      if (FileContext->FileHandle != NULL) {
>        FileContext->FileHandle->Close (FileContext->FileHandle);
>      }
>    }
> @@ -313,11 +315,13 @@ LibDestroyMenuEntry (
>      FreePool (FileContext->FileName);
>    }
> 
>    FreePool (FileContext);
> 
> -  FreePool (MenuEntry->DisplayString);
> +  if (MenuEntry->DisplayString != NULL) {
> +    FreePool (MenuEntry->DisplayString);
> +  }
>    if (MenuEntry->HelpString != NULL) {
>      FreePool (MenuEntry->HelpString);
>    }
> 
>    FreePool (MenuEntry);
> --
> 1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to