dense-analysis / dense-analysis/ale
Cppcheck misses memory leak issues.
- 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
Assessment
This issue has not been assessed yet.