Skip to content

Commit f5c0bb8

Browse files
committed
1 parent 5bb956b commit f5c0bb8

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

samples/memleak/bad.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdlib.h>
2+
int main()
3+
{
4+
int result;
5+
char *a = malloc(10);
6+
a[0] = 0;
7+
result = a[0];
8+
return result;
9+
}

samples/memleak/good.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdlib.h>
2+
int main()
3+
{
4+
int result;
5+
char *a = malloc(10);
6+
a[0] = 0;
7+
result = a[0];
8+
free(a);
9+
return result;
10+
}
11+

samples/resourceLeak/a.out

8.24 KB
Binary file not shown.

samples/resourceLeak/bad.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
FILE *a = fopen("good.c", "r");
5+
if (!a)
6+
return 0;
7+
8+
return 0;
9+
}
10+

samples/resourceLeak/good.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
FILE *a = fopen("good.c", "r");
5+
if (!a)
6+
return 0;
7+
fclose(a);
8+
return 0;
9+
}
10+

0 commit comments

Comments
 (0)