Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rdemeter
GitHub Repository: rdemeter/so
Path: blob/master/lab4/valgrind_test.c
221 views
1
#include <stdlib.h>
2
#include <string.h>
3
4
int main(void)
5
{
6
char buf[10];
7
char *p;
8
/* no init */
9
strcat(buf, "al");
10
/* overflow */
11
buf[11] = 'a';
12
p = malloc(70);
13
p[10] = 5;
14
free(p);
15
/* write after free */
16
p[1] = 'a';
17
p = malloc(10);
18
/* memory leak */
19
p = malloc(10);
20
/* underrun */
21
p--;
22
*p = 'a';
23
return 0;
24
}
25
26
27
28