mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
BaseTools/GenFfs: Fix return too early when input file is of size 0
Commit 2cb874352423fcfd180199e6de8298567dff8e7f eliminates possible NULL pointer dereference in GenFfs tool source codes. However, it doesn't correctly handle the case when the input file is of size 0. This will lead to possible build issues. This commits refine the logic to handle the above case. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
8009b2e47f
commit
b390737ad0
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user