Fixing #3515 (Add samples/id/good|bad.cpp)

http://sourceforge.net/apps/trac/cppcheck/ticket/3515
This commit is contained in:
Reijo Tomperi 2012-01-22 16:14:13 +02:00
parent 5bb956b0ff
commit f5c0bb822d
5 changed files with 40 additions and 0 deletions

9
samples/memleak/bad.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdlib.h>
int main()
{
int result;
char *a = malloc(10);
a[0] = 0;
result = a[0];
return result;
}

11
samples/memleak/good.c Normal file
View File

@ -0,0 +1,11 @@
#include <stdlib.h>
int main()
{
int result;
char *a = malloc(10);
a[0] = 0;
result = a[0];
free(a);
return result;
}

BIN
samples/resourceLeak/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,10 @@
#include <stdio.h>
int main()
{
FILE *a = fopen("good.c", "r");
if (!a)
return 0;
return 0;
}

View File

@ -0,0 +1,10 @@
#include <stdio.h>
int main()
{
FILE *a = fopen("good.c", "r");
if (!a)
return 0;
fclose(a);
return 0;
}