Add pointer check for NULL before dereference it.
Signed-off-by: ydong10 Reviewed-by: rsun3, lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12472 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -341,6 +341,7 @@ FindStringBlock (
|
||||
for (Index = 0; Index < StringCount; Index++) {
|
||||
BlockSize += AsciiStrSize ((CHAR8 *) StringTextPtr);
|
||||
if (CurrentStringId == StringId) {
|
||||
ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);
|
||||
*BlockType = *BlockHdr;
|
||||
*StringBlockAddr = BlockHdr;
|
||||
*StringTextOffset = StringTextPtr - BlockHdr;
|
||||
@ -363,6 +364,7 @@ FindStringBlock (
|
||||
for (Index = 0; Index < StringCount; Index++) {
|
||||
BlockSize += AsciiStrSize ((CHAR8 *) StringTextPtr);
|
||||
if (CurrentStringId == StringId) {
|
||||
ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);
|
||||
*BlockType = *BlockHdr;
|
||||
*StringBlockAddr = BlockHdr;
|
||||
*StringTextOffset = StringTextPtr - BlockHdr;
|
||||
@ -406,6 +408,7 @@ FindStringBlock (
|
||||
GetUnicodeStringTextOrSize (NULL, StringTextPtr, &StringSize);
|
||||
BlockSize += StringSize;
|
||||
if (CurrentStringId == StringId) {
|
||||
ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);
|
||||
*BlockType = *BlockHdr;
|
||||
*StringBlockAddr = BlockHdr;
|
||||
*StringTextOffset = StringTextPtr - BlockHdr;
|
||||
@ -429,6 +432,7 @@ FindStringBlock (
|
||||
GetUnicodeStringTextOrSize (NULL, StringTextPtr, &StringSize);
|
||||
BlockSize += StringSize;
|
||||
if (CurrentStringId == StringId) {
|
||||
ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);
|
||||
*BlockType = *BlockHdr;
|
||||
*StringBlockAddr = BlockHdr;
|
||||
*StringTextOffset = StringTextPtr - BlockHdr;
|
||||
@ -572,7 +576,7 @@ FindStringBlock (
|
||||
//
|
||||
// Get last string ID
|
||||
//
|
||||
if (StringId == (EFI_STRING_ID) (-1)) {
|
||||
if (StringId == (EFI_STRING_ID) (-1) && LastStringId != NULL) {
|
||||
*LastStringId = (EFI_STRING_ID) (CurrentStringId - 1);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user