The UEFI specification does not say anything when the pointers passed to

WaitForEvent() are NULL.
Passing NULL pointer would cause a segmentation fault in the current code.
This change prevents to get segmentation faults in this case.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15643 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-07-09 05:19:24 +00:00 committed by erictian
parent e364478661
commit 720f84a9d3
1 changed files with 12 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file
UEFI Event support functions implemented in this file.
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -673,6 +673,14 @@ CoreWaitForEvent (
return EFI_UNSUPPORTED;
}
if (NumberOfEvents == 0) {
return EFI_INVALID_PARAMETER;
}
if (UserEvents == NULL) {
return EFI_INVALID_PARAMETER;
}
for(;;) {
for(Index = 0; Index < NumberOfEvents; Index++) {
@ -683,7 +691,9 @@ CoreWaitForEvent (
// provide index of event that caused problem
//
if (Status != EFI_NOT_READY) {
*UserIndex = Index;
if (UserIndex != NULL) {
*UserIndex = Index;
}
return Status;
}
}