summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/BaseSortLib/BaseSortLib.c29
-rw-r--r--ShellPkg/Library/UefiSortLib/UefiSortLib.c28
2 files changed, 32 insertions, 25 deletions
diff --git a/ShellPkg/Library/BaseSortLib/BaseSortLib.c b/ShellPkg/Library/BaseSortLib/BaseSortLib.c
index 2d3f190324..b26d971270 100644
--- a/ShellPkg/Library/BaseSortLib/BaseSortLib.c
+++ b/ShellPkg/Library/BaseSortLib/BaseSortLib.c
@@ -109,20 +109,23 @@ QuickSortWorker (
// Now recurse on 2 paritial lists. neither of these will have the 'pivot' element
// IE list is sorted left half, pivot element, sorted right half...
//
- QuickSortWorker(
- BufferToSort,
- NextSwapLocation,
- ElementSize,
- CompareFunction,
- Buffer);
-
- QuickSortWorker(
- (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
- Count - NextSwapLocation - 1,
- ElementSize,
- CompareFunction,
- Buffer);
+ if (NextSwapLocation >= 2) {
+ QuickSortWorker(
+ BufferToSort,
+ NextSwapLocation,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
+ if ((Count - NextSwapLocation - 1) >= 2) {
+ QuickSortWorker(
+ (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
+ Count - NextSwapLocation - 1,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
return;
}
/**
diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.c b/ShellPkg/Library/UefiSortLib/UefiSortLib.c
index 7cbff34cca..62d6eaabb8 100644
--- a/ShellPkg/Library/UefiSortLib/UefiSortLib.c
+++ b/ShellPkg/Library/UefiSortLib/UefiSortLib.c
@@ -118,19 +118,23 @@ QuickSortWorker (
// Now recurse on 2 paritial lists. neither of these will have the 'pivot' element
// IE list is sorted left half, pivot element, sorted right half...
//
- QuickSortWorker(
- BufferToSort,
- NextSwapLocation,
- ElementSize,
- CompareFunction,
- Buffer);
+ if (NextSwapLocation >= 2) {
+ QuickSortWorker(
+ BufferToSort,
+ NextSwapLocation,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
- QuickSortWorker(
- (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
- Count - NextSwapLocation - 1,
- ElementSize,
- CompareFunction,
- Buffer);
+ if ((Count - NextSwapLocation - 1) >= 2) {
+ QuickSortWorker(
+ (UINT8 *)BufferToSort + (NextSwapLocation+1) * ElementSize,
+ Count - NextSwapLocation - 1,
+ ElementSize,
+ CompareFunction,
+ Buffer);
+ }
return;
}