aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/malloc.c
blob: 270b3d1b6959b644f811fcd69ffa22481e31b8da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// RUN: clang-cc -analyze -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s
#include <stdlib.h>

void f1() {
  int *p = malloc(10);
  return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
}

void f2() {
  int *p = malloc(10);
  free(p);
  free(p); // expected-warning{{Try to free a memory block that has been released}}
}