lundi 29 juin 2020

Memory leak when using fortify static code analyser for unique_ptr

Using std::unique_ptr in c++11 in fortify Static Code Analyser is giving me a memory leak.

void *httpServerThread(void *arg)
{
  
    std::unique_ptr <int> i(new int(1));
    return NULL;
}

Meanwhile, the below code shows no memory leak.

void *httpServerThread(void *arg)
{
  
    int * i  = new int(1);
    delete i;
    return NULL;
}

Since there is no std::make_unique, there is no way to create std::unique_ptr without new. I am using the 19.2.0 version of fortify -> Fortify_SCA_and_Apps_19.2.0. Any suggestion would be welcome.

Aucun commentaire:

Enregistrer un commentaire