File: stacktest.c

package info (click to toggle)
debauch 0.3-11
  • links: PTS
  • area: main
  • in suites: potato
  • size: 220 kB
  • ctags: 685
  • sloc: ansic: 2,136; makefile: 531; sh: 84; asm: 34
file content (38 lines) | stat: -rw-r--r-- 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 *
 * do more dumb things with memory in a deeper stack to test the stack trace
 *
 */

sub4(int *a)
{
  free(a);
  a[0]=1;  /* reference free'd memory */
}

sub3(int *a)
{
  int b;
  char *c;
  sub4(a);
  c=strdup("This memory won't be free'd.  It's a leak");
}

sub2(int *a)
{
  int c;
  sub3(a);
}

sub1(int *a)
{
  int d,e,f,g;
  sub2(a);
}

main()
{
  int *a=malloc(1);
  sub1(a);
  exit(1);
}