Skip to content

Commit d2143a1

Browse files
authored
Fix Potential NULL Pointer Dereference (#205)
1 parent 15a209c commit d2143a1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Library/MemLogLib/BootLog.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,25 @@ EFI_FILE_PROTOCOL * GetDebugLogFile (VOID) {
184184
//
185185
// Get mRootDir from the device we are loaded from
186186
mRootDir = EfiLibOpenRoot (LoadedImage->DeviceHandle);
187-
188187
LogProtocol = OpenLogFile();
189-
Status = REFIT_CALL_1_WRAPPER(mRootDir->Close, mRootDir);
188+
if (mRootDir == NULL) {
189+
Status = EFI_NOT_READY;
190+
}
191+
else {
192+
Status = REFIT_CALL_1_WRAPPER(mRootDir->Close, mRootDir);
193+
}
190194
if (EFI_ERROR(Status)) {
191195
// Try on first EFI partition
192196
mRootDir = NULL;
193197
Status = egFindESP (&mRootDir);
194198
if (!EFI_ERROR(Status)) {
195199
LogProtocol = OpenLogFile();
196-
Status = REFIT_CALL_1_WRAPPER(mRootDir->Close, mRootDir);
200+
if (mRootDir == NULL) {
201+
Status = EFI_NOT_READY;
202+
}
203+
else {
204+
Status = REFIT_CALL_1_WRAPPER(mRootDir->Close, mRootDir);
205+
}
197206
}
198207

199208
if (EFI_ERROR(Status)) {

0 commit comments

Comments
 (0)