Add TD7
This commit is contained in:
parent
4296f3a394
commit
553cdc440c
24 changed files with 919 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
CFLAGS=-g -Wall -Wextra -Wno-unused-parameter
|
||||
LDLIBS=-lpthread
|
||||
C=$(wildcard *.c)
|
||||
O=$(C:.c=)
|
||||
A=$(C:.c=.asan)
|
||||
L=$(C:.c=.lsan)
|
||||
U=$(C:.c=.usan)
|
||||
T=$(C:.c=.tsan)
|
||||
|
||||
all: $O $A $U $T
|
||||
|
||||
%.asan: %.c
|
||||
$(CC) -fsanitize=address -fPIC $< -o $@ $(CFLAGS) $(LDLIBS)
|
||||
%.lsan: %.c
|
||||
$(CC) -fsanitize=leak -fPIC $< -o $@ $(CFLAGS) $(LDLIBS)
|
||||
%.usan: %.c
|
||||
$(CC) -fsanitize=undefined -fPIC $< -o $@ $(CFLAGS) $(LDLIBS)
|
||||
%.tsan: %.c
|
||||
$(CC) -fsanitize=thread -fPIC $< -o $@ $(CFLAGS) $(LDLIBS)
|
||||
|
||||
clean:
|
||||
rm -f $O $A $L $U $T
|
|
@ -0,0 +1,24 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static char *f(void) {
|
||||
char *c = malloc(10);
|
||||
char *d = malloc(20);
|
||||
c[0] = 0;
|
||||
d[0] = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
static void g(void) {
|
||||
char *e = f();
|
||||
printf("%p\n", e);
|
||||
}
|
||||
|
||||
static void h(void) {
|
||||
g();
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
h();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
char *c;
|
||||
|
||||
int main(void) {
|
||||
c = malloc(10);
|
||||
c[0] = 0;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue