File: test.cc

package info (click to toggle)
leaktracer 2.4-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 100 kB
  • ctags: 74
  • sloc: cpp: 354; makefile: 86; perl: 67; sh: 17
file content (17 lines) | stat: -rw-r--r-- 320 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Small leaky test program

void foo() {
    int *x = new int;
}

int main() {
    int *z = new int[10];
    char *q = new char[4];
    q[4] = 'x';                 // MAGIC overrun
    // Commenting out should make this abort
    // delete q;
    foo();
    foo();
    delete z;
    delete z;   // delete value twice
}