cppcheck/test/testsuites/duma/leak2.c

21 lines
385 B
C
Raw Normal View History

2019-03-18 06:58:12 +01:00
#include <stdio.h>
int main() {
2021-08-07 20:51:18 +02:00
printf("Hello world!\n");
2019-03-18 06:58:12 +01:00
2021-08-07 20:51:18 +02:00
int* pI;
pI = (int*)malloc(10*sizeof(int));
2019-03-18 06:58:12 +01:00
2021-08-07 20:51:18 +02:00
printf("Let's leak a pointer to an array of 10 ints\n");
int i=0;
for (i=0; i<9; i++) {
pI[i] = 303+i;
}
int j=0;
for (j=0; j<9; j++) {
if (pI[j] != 303+j) printf(" Something strange is happening...\n");
}
2019-03-18 06:58:12 +01:00
2021-08-07 20:51:18 +02:00
return 0;
2019-03-18 06:58:12 +01:00
}