X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FGenSec%2FGenSec.c;fp=BaseTools%2FSource%2FC%2FGenSec%2FGenSec.c;h=fb5bc5e9925403cf4d01cbb100561003c6986cc7;hb=c40dbe5e7bf9f3f841d4f1c717c245e99854b786;hp=01d3bc4448089fdd30543e7f567346bf82217697;hpb=ae0fbb7f5ad41866bca89320f501282e173b373d;p=mirror_edk2.git diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index 01d3bc4448..fb5bc5e992 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1333,10 +1333,20 @@ Returns: DummyFileSize = ftell (DummyFile); fseek (DummyFile, 0, SEEK_SET); DummyFileBuffer = (UINT8 *) malloc (DummyFileSize); + if (DummyFileBuffer == NULL) { + fclose(DummyFile); + Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated"); + goto Finish; + } + fread(DummyFileBuffer, 1, DummyFileSize, DummyFile); fclose(DummyFile); DebugMsg (NULL, 0, 9, "Dummy files", "the dummy file name is %s and the size is %u bytes", DummyFileName, (unsigned) DummyFileSize); + if (InputFileName == NULL) { + Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated"); + goto Finish; + } InFile = fopen(LongFilePath(InputFileName[0]), "rb"); if (InFile == NULL) { Error (NULL, 0, 0001, "Error opening file", InputFileName[0]); @@ -1347,6 +1357,12 @@ Returns: InFileSize = ftell (InFile); fseek (InFile, 0, SEEK_SET); InFileBuffer = (UINT8 *) malloc (InFileSize); + if (InFileBuffer == NULL) { + fclose(InFile); + Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated"); + goto Finish; + } + fread(InFileBuffer, 1, InFileSize, InFile); fclose(InFile); DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and the size is %u bytes", InputFileName[0], (unsigned) InFileSize);