avector index out of bound issue C++
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 55/100
Research direction
Start from the shortBubbleSort function shown in the issue and reproduce the invalid read with a vector of four integers, using the project's available checks or a memory checker. Done means the sort handles the final comparison without accessing beyond the vector and still returns correctly sorted values.
Written by the indexing model from the issue text.
Description
vector shortBubbleSort(vector avector){ //the vector for bubble sort
bool exchanges = true;
int passnum = avector.size();
//while vector size is greater than 0 and exchanges = true
while (passnum > 0 && exchanges) {
exchanges = false;
//loops through vector, exchanging values until it reaches the end of vector.
for(int i = 0; i < passnum; i++){
if(avector[i] > avector[i+1]){
exchanges = true;
int temp = avector[i];
avector[i] = avector[i+1];
avector[i+1] = temp;
}
}
//subtracts from the passnum variable so that the next passthrough is one less
//than the previous, because the largest value has already 'bubbled' all the way up.
passnum = passnum - 1;
}
return avector;
The comparison of avector[i] with avector[i + 1] is going to create an issue when we are comparing the last element. The error will be as follows: "Invalid read of size 4" for avector of size four.
- Dominant language
- Python
- Stars
- 274
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RunestoneInteractive/pythonds
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
RunestoneInteractive/pythonds#109 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
RunestoneInteractive/pythonds#126 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 52/100
RunestoneInteractive/pythonds#120 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
RunestoneInteractive/pythonds#99 · 5 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
RunestoneInteractive/pythonds#96 · 1 comment ·
All issues in RunestoneInteractive/pythonds
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
conda-forge/conda-build-feedstock#289 · 1 comment · 1 reaction ·
-
`pulptest` no longer works in 4.0.0: `ImportError: Start directory is not importable: 'pulp/tests'`Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
remove reddit feedsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
TomCasavant/ohio-sites#224 ·