libluna: Fix a crash in quicksort
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-05-28 21:51:39 +02:00
parent 069f1c0f97
commit 51a5727c8d
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -1,4 +1,5 @@
#include <luna/Alignment.h>
#include <luna/DebugLog.h>
#include <luna/Sort.h>
static void swap_sized(void* ptr1, void* ptr2, usize size)
@ -42,7 +43,7 @@ static void quicksort_impl(void* base, usize start, usize end, usize size, compa
{
usize pivot = partition(base, start, end, size, compar);
if ((end - start) < 2) return;
quicksort_impl(base, start, pivot - 1, size, compar);
if (pivot > 0) quicksort_impl(base, start, pivot - 1, size, compar);
quicksort_impl(base, pivot + 1, end, size, compar);
}
}