From 9a707af2e30cbfb807d2e1f1f7ad5d877981ab8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 10 Mar 2024 16:20:16 +0100 Subject: [PATCH] [FREELDR] Initialize CandidatePageCount to zero, needed if the while-loop is not run. Granted, if the while-loop is not run, this means there is no memory available at all on the computer where FreeLdr is running, which is quite unexpected. But do the initialization anyways, in order to avoid more obscure bugs down the line. On the other hand, PageLookupTableMemAddress doesn't need to be pre-initialized, since it gets initialized unconditionally afterwards. --- boot/freeldr/freeldr/lib/mm/meminit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/freeldr/freeldr/lib/mm/meminit.c b/boot/freeldr/freeldr/lib/mm/meminit.c index aacccda4800..953b6596330 100644 --- a/boot/freeldr/freeldr/lib/mm/meminit.c +++ b/boot/freeldr/freeldr/lib/mm/meminit.c @@ -419,9 +419,9 @@ PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount) SIZE_T PageLookupTableSize; PFN_NUMBER RequiredPages; PFN_NUMBER CandidateBasePage = 0; - PFN_NUMBER CandidatePageCount; + PFN_NUMBER CandidatePageCount = 0; PFN_NUMBER PageLookupTableEndPage; - PVOID PageLookupTableMemAddress = NULL; + PVOID PageLookupTableMemAddress; // Calculate how much pages we need to keep the page lookup table PageLookupTableSize = TotalPageCount * sizeof(PAGE_LOOKUP_TABLE_ITEM);