summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/GenFfs/GenFfs.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c
index 78e5097fb4..c5d657bd09 100644
--- a/BaseTools/Source/C/GenFfs/GenFfs.c
+++ b/BaseTools/Source/C/GenFfs/GenFfs.c
@@ -842,7 +842,12 @@ Returns:
);
}
- if (EFI_ERROR (Status) || (FileBuffer == NULL)) {
+ if (EFI_ERROR (Status)) {
+ goto Finish;
+ }
+
+ if (FileBuffer == NULL && FileSize != 0) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
goto Finish;
}
@@ -929,7 +934,9 @@ Returns:
//
// write data
//
- fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
+ if (FileBuffer != NULL) {
+ fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
+ }
fclose (FfsFile);
}