]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/BootManagerMenu: Add assertion to indicate no DIV by 0
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 11 Apr 2017 02:07:43 +0000 (10:07 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 14 Apr 2017 10:28:50 +0000 (18:28 +0800)
BootMenuSelectItem() contains code to DIV BootMenuData->ItemCount.
When BootMenuData->ItemCount can be 0, the DIV operation may
trigger CPU exception.
But in logic, this case won't happen. So add assertion to indicate
it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c

index 6d493e1250cdffc5d1e614a450c8c066d3e0ea61..a25f2ca298c758ee6e7e145b79ebe2cd25ed17b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The application to show the Boot Manager Menu.\r
 \r
-Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -374,6 +374,7 @@ BootMenuSelectItem (
   if (BootMenuData == NULL || WantSelectItem >= BootMenuData->ItemCount) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+  ASSERT (BootMenuData->ItemCount != 0);\r
   SavedAttribute = gST->ConOut->Mode->Attribute;\r
   RePaintItems = FALSE;\r
   StartCol = BootMenuData->MenuScreen.StartCol;\r