From 9a85313bc68fde2a79e17e51726bab55eb3d85ac Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 18 Sep 2013 16:12:51 +0200 Subject: [PATCH] X86PagingStructuresPAE: Zero fPageDirPointerTable in constructor ... and use it as a guard in the destructor. Fixes crash when running out of memory and Init() is not called. --- .../kernel/arch/x86/paging/pae/X86PagingStructuresPAE.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingStructuresPAE.cpp b/src/system/kernel/arch/x86/paging/pae/X86PagingStructuresPAE.cpp index efffa60ee2..99e3f1db0e 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingStructuresPAE.cpp +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingStructuresPAE.cpp @@ -20,6 +20,8 @@ X86PagingStructuresPAE::X86PagingStructuresPAE() + : + fPageDirPointerTable(NULL) { memset(fVirtualPageDirs, 0, sizeof(fVirtualPageDirs)); } @@ -32,8 +34,10 @@ X86PagingStructuresPAE::~X86PagingStructuresPAE() // There's one contiguous allocation for 0 and 1. // free the PDPT page - X86PagingMethodPAE::Method()->Free32BitPage(fPageDirPointerTable, - pgdir_phys, fPageDirPointerTableHandle); + if (fPageDirPointerTable != NULL) { + X86PagingMethodPAE::Method()->Free32BitPage(fPageDirPointerTable, + pgdir_phys, fPageDirPointerTableHandle); + } }