ShellPkg: Add checks for NULL pointers.
This adds lots of pointer verification with ASSERTs only used when the condition should be impossible and never for memory allocation. signed-off-by: jcarsey reviewed-by: geekboy15a git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12523 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -1327,7 +1327,8 @@ FileInterfaceMemGetPosition(
|
||||
@param[in, out] BufferSize Size in bytes of Buffer.
|
||||
@param[in] Buffer The pointer to the buffer to write.
|
||||
|
||||
@retval EFI_SUCCESS The data was written.
|
||||
@retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.
|
||||
@retval EFI_SUCCESS The data was written.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@@ -1354,6 +1355,9 @@ FileInterfaceMemWrite(
|
||||
// Ascii
|
||||
//
|
||||
AsciiBuffer = AllocateZeroPool(*BufferSize);
|
||||
if (AsciiBuffer == NULL) {
|
||||
return (EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
|
||||
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {
|
||||
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);
|
||||
|
Reference in New Issue
Block a user