diff --git a/Makefile.local.asan b/Makefile.local.asan new file mode 100644 index 0000000000..61a54718a8 --- /dev/null +++ b/Makefile.local.asan @@ -0,0 +1,7 @@ +# Compiles with ASan (https://github.com/google/sanitizers/wiki/AddressSanitizer) +# How to use: +# cp Makefile.local.asan Makefile.local && make +CC=clang +CFLAGS+=-fsanitize=address +CFLAGS+=-g +CFLAGS+=-fsanitize-blacklist=asan_ignore.txt diff --git a/asan_ignore.txt b/asan_ignore.txt new file mode 100644 index 0000000000..7c87f32f87 --- /dev/null +++ b/asan_ignore.txt @@ -0,0 +1 @@ +fun:VM_Call diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c index 31a6a4d981..ebab835931 100644 --- a/code/client/cl_cgame.c +++ b/code/client/cl_cgame.c @@ -618,7 +618,9 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) { Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case CG_STRNCPY: - strncpy( VMA(1), VMA(2), args[3] ); + if (VMA(1) != VMA(2)) { + strncpy( VMA(1), VMA(2), args[3] ); + } return args[1]; case CG_SIN: return FloatAsInt( sin( VMF(1) ) );