Skip to content

Commit

Permalink
examples/sort.c: fix out-of-bound memory access
Browse files Browse the repository at this point in the history
Issue described in drh#9
and also in book's errata.
  • Loading branch information
juniskane committed Mar 21, 2023
1 parent 349e078 commit 3872d23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int partition(int a[], int i, int j) {
k = i;
v = a[k];
while (i < j) {
i++; while (a[i] < v && i < j) i++;
i++; while (i < j && a[i] < v) i++;
j--; while (a[j] > v ) j--;
if (i < j) { t = a[i]; a[i] = a[j]; a[j] = t; }
}
Expand Down

0 comments on commit 3872d23

Please sign in to comment.