Skip to content

Commit 56779b1

Browse files
committed
Add SANITIZE=1 option
1 parent 182d693 commit 56779b1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

common/rules.mk

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ O ?= -O3
77
ifeq ($(filter 0 1 2 3 s,$(O)),$(strip $(O)))
88
override O := -O$(O)
99
endif
10+
ifeq ($(SANITIZE),1)
11+
CC += -fsanitize=address -fsanitize=undefined
12+
endif
1013

1114
# these rules ensure dependencies are created
1215
DEPCFLAGS = -MD -MF $(DEPSDIR)/$*.d -MP

fundamentals3/addrspace.c

+2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ int main(int argc, char* argv[]) {
1818
printf("Address of a const local variable\t%p\n", &const_local_ch);
1919
printf("Address of a heap variable\t\t%p\n", heap_ch);
2020
printf("Address of main\t\t\t\t%p\n", main);
21+
22+
free(heap_ch);
2123
return 0;
2224
}

0 commit comments

Comments
 (0)