Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c652c4f

Browse files
authored
fix: stack buffer underflow in tim_sort.cpp (TheAlgorithms#2722)
1 parent b6108e4 commit c652c4f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎sorting/tim_sort.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void insertionSort(int arr[], int left, int right) {
1212
for (int i = left + 1; i <= right; i++) {
1313
const int temp = arr[i];
1414
int j = i - 1;
15-
while (arr[j] > temp && j >= left) {
15+
while (j >= left && arr[j] > temp) {
1616
arr[j + 1] = arr[j];
1717
j--;
1818
}
@@ -92,7 +92,7 @@ void printArray(int arr[], int n) {
9292
}
9393

9494
/**
95-
* @brief self-test implementation
95+
* @brief self-test implementation
9696
* @returns void
9797
*/
9898
void tests() {
@@ -110,7 +110,7 @@ void tests() {
110110

111111
// Driver program to test above function
112112
int main() {
113-
tests(); // run self test implementations
113+
tests(); // run self test implementations
114114

115115
int arr[] = {5, 21, 7, 23, 19};
116116
const int n = sizeof(arr) / sizeof(arr[0]);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /