dense-analysis / dense-analysis/ale

Cppcheck misses memory leak issues.

Open
#3,534 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

Reported by @zchrissirhcz at https://github.com/dense-analysis/ale/pull/3030#issuecomment-757605514

While this PR #3030 fix the output of cppcheck since cppcheck 1.89, I found that cppcheck>=1.89 failed to detect memory leak like this:
```
#include
#include
#include

void ss() {
FILE* fp = fopen("some.txt", "w");
if (fp==NULL) {
printf("file is not writable error is %d\n", errno);
} else {
printf("file is writable\n");
}
fclose(fp);
}

int main(){
int* data = (int*)malloc(sizeof(int)*100);
for (int i=0; i<100; i++) {
data[i] = i + 1 + 2;
}

return 0;
}
```

Meanwhile on ubuntu16.04 apt provided cppcheck version is 1.72, it can detect that leak:

```
Checking main.cpp...
[main.cpp:21]: (error) Memory leak: data
```

Thus fallback to 40441960477e4ca0028eb287dfe25c4c1dea8a27 commit for my scenario.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.