SonarQube is not reporting memory leaks


(Swetha) #1


Below is my code

#include <stdlib.h>

int v_error() {
  int* p = new int;
  *p = 2;

  int* u = (int *)malloc(sizeof(int));
  *u = 4;

  return *p + *u;

While i was analysing this code,sonarqube is not reporting memory leak at line 4 but it is reporting memory leak at 7.
Could you please suggest me how to fix this.


(Massimo Paladin) #2

Hi @swetha,

we apologise but we missed your topic. We anyway would like to recommend you trying the latest version of our analyser which is shipped in SonarQube 7.5 or available on SonarCloud.