summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2019-11-09 00:35:46 +0000
committerChristos Zoulas <christos@zoulas.com>2019-11-09 00:35:46 +0000
commit87f6cacd7496978729f91a8c11b697ce2c91405f (patch)
tree79e3280c11db8d9e7876f91c5453172cbcf4223f
parentaa28a784c7a7c4ba3e60e09db485e781cbb667b0 (diff)
downloadfile-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.c5
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);
}