facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.92k stars 2.01k forks source link

Infer cannot report memory leak caused by new? #1839

Closed u201111476 closed 3 months ago

u201111476 commented 3 months ago

I have a cpp source file,whose contents are as below:

#include<stdio.h>
#include<stdlib.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char* buf=new char;
  *buf='c';
  cout<<buf<<endl;
  return 0;
}

then I use infer capture -- clang++ main.cpp and infer analyze --bufferoverrun --pulse,but infer does not check out the obvious memory leak caused by new,what should I do to check out this real flaw?