https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2fb2f1e4c57b453a8a67b…
commit 2fb2f1e4c57b453a8a67b4a54ad72533acf0a8b1
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sun Aug 16 16:18:25 2020 +0200
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sun Aug 16 16:18:29 2020 +0200
[RTL] Allow RtlGetNextRange to be called on a finished iterator. CORE-6372
Fixes crash in kmtest:RtlRangeList.
---
sdk/lib/rtl/rangelist.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sdk/lib/rtl/rangelist.c b/sdk/lib/rtl/rangelist.c
index ab2de3e0369..e589d43812a 100644
--- a/sdk/lib/rtl/rangelist.c
+++ b/sdk/lib/rtl/rangelist.c
@@ -499,6 +499,12 @@ RtlGetNextRange(IN OUT PRTL_RANGE_LIST_ITERATOR Iterator,
if (Iterator->Stamp != RangeList->Stamp)
return STATUS_INVALID_PARAMETER;
+ if (Iterator->Current == NULL)
+ {
+ *Range = NULL;
+ return STATUS_NO_MORE_ENTRIES;
+ }
+
if (MoveForwards)
{
Next = ((PRTL_RANGE_ENTRY)Iterator->Current)->Entry.Flink;
@@ -509,7 +515,11 @@ RtlGetNextRange(IN OUT PRTL_RANGE_LIST_ITERATOR Iterator,
}
if (Next == Iterator->RangeListHead)
+ {
+ Iterator->Current = NULL;
+ *Range = NULL;
return STATUS_NO_MORE_ENTRIES;
+ }
Iterator->Current = Next;
*Range = &((PRTL_RANGE_ENTRY)Next)->Range;