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 6393130

Browse files
authored
fix: resize array to avoid arrayIndexOutOfBounds (TheAlgorithms#2979)
1 parent 145111c commit 6393130

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎search/linear_search.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ static void tests() {
4545
assert(LinearSearch(array, size, 1) == 1);
4646
assert(LinearSearch(array, size, 2) == 2);
4747

48+
delete[] array;
49+
4850
size = 6;
51+
array = new int[size];
4952
for (int i = 0; i < size; i++) {
5053
array[i] = i;
5154
}

0 commit comments

Comments
(0)

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