https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c0bf352069bd0c1b0d51d…
commit c0bf352069bd0c1b0d51da64c48fda70bb3ba92a
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Feb 1 18:20:18 2021 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Feb 3 09:41:24 2021 +0100
[NTOS:MM] Fix regression of MmCanFileBeTruncated
---
ntoskrnl/mm/section.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c
index d848e337038..62da435122e 100644
--- a/ntoskrnl/mm/section.c
+++ b/ntoskrnl/mm/section.c
@@ -4115,7 +4115,7 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS
SectionObjectPointer,
}
MmLockSectionSegment(Segment);
- if ((Segment->SectionCount == 1) &&
(SectionObjectPointer->SharedCacheMap != NULL))
+ if ((Segment->SectionCount == 0) || ((Segment->SectionCount == 1) &&
(SectionObjectPointer->SharedCacheMap != NULL)))
{
/* If the cache is the only one holding a reference to the segment, then it's
fine to resize */
Ret = TRUE;
@@ -4124,6 +4124,12 @@ MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS
SectionObjectPointer,
{
/* We can't shrink, but we can extend */
Ret = NewFileSize->QuadPart >= Segment->RawLength.QuadPart;
+#if DBG
+ if (!Ret)
+ {
+ DPRINT1("Cannot truncate data: New Size %I64d, Segment Size
%I64d\n", NewFileSize->QuadPart, Segment->RawLength.QuadPart);
+ }
+#endif
}
MmUnlockSectionSegment(Segment);
MmDereferenceSegment(Segment);