Merge pull request #802 from pcercuei/address-sanitizer
authornotaz <notasas@gmail.com>
Sun, 19 Nov 2023 22:42:16 +0000 (00:42 +0200)
committerGitHub <noreply@github.com>
Sun, 19 Nov 2023 22:42:16 +0000 (00:42 +0200)
Address sanitizer

Makefile
frontend/menu.c

index be94391..57fee2f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,9 @@ else
 CFLAGS += -O2 -DNDEBUG
 endif
 endif
+ifeq ($(DEBUG_ASAN), 1)
+CFLAGS += -fsanitize=address
+endif
 CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \
          -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \
          -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \
@@ -45,6 +48,9 @@ endif
 CC_LINK ?= $(CC)
 CC_AS ?= $(CC)
 LDFLAGS += $(MAIN_LDFLAGS)
+ifeq ($(DEBUG_ASAN), 1)
+LDFLAGS += -static-libasan
+endif
 EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
 LDLIBS += $(MAIN_LDLIBS)
 ifdef PCNT
index 9200e10..413f3ca 100644 (file)
@@ -217,7 +217,7 @@ static int optional_cdimg_filter(struct dirent **namelist, int count,
        const char *basedir)
 {
        const char *ext, *p;
-       char buf[256], buf2[256];
+       char buf[256], buf2[257];
        int i, d, ret, good_cue;
        struct STAT statf;
        FILE *f;