diff options
author | Christos Zoulas <christos@zoulas.com> | 2019-11-09 00:35:46 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2019-11-09 00:35:46 +0000 |
commit | 87f6cacd7496978729f91a8c11b697ce2c91405f (patch) | |
tree | 79e3280c11db8d9e7876f91c5453172cbcf4223f | |
parent | aa28a784c7a7c4ba3e60e09db485e781cbb667b0 (diff) | |
download | file-git-87f6cacd7496978729f91a8c11b697ce2c91405f.tar.gz |
Pr/119: atrosinenko, appease sanitizer, don't call memset with a null pointer
when the size == 0
-rw-r--r-- | src/funcs.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/funcs.c b/src/funcs.c index 4dfbfd7c..9cdec018 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.107 2019/09/11 15:46:30 christos Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.108 2019/11/09 00:35:46 christos Exp $") #endif /* lint */ #include "magic.h" @@ -573,7 +573,8 @@ file_regexec(file_regex_t *rx, const char *str, size_t nmatch, { assert(rx->rc == 0); /* XXX: force initialization because glibc does not always do this */ - memset(pmatch, 0, nmatch * sizeof(*pmatch)); + if (nmatch != 0) + memset(pmatch, 0, nmatch * sizeof(*pmatch)); return regexec(&rx->rx, str, nmatch, pmatch, eflags); } |