summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-09-06 17:13:04 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-09-06 17:13:04 -0400
commitdc0443270904bf623d5b4a8e7b9ed8467eb9c93c (patch)
tree355c6e80724906810411690611a7c9fa50db8635 /src/bfstd.c
parent4f9762218079c4d83eb30065804367506da8330d (diff)
downloadbfs-dc0443270904bf623d5b4a8e7b9ed8467eb9c93c.tar.xz
bfstd: Work around a FreeBSD-specific msan issue
Link: https://github.com/llvm/llvm-project/issues/65532
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/bfstd.c b/src/bfstd.c
index c858910..1a5a67d 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -5,6 +5,7 @@
#include "bit.h"
#include "config.h"
#include "diag.h"
+#include "sanity.h"
#include "thread.h"
#include "xregex.h"
#include <ctype.h>
@@ -590,11 +591,20 @@ static unsigned char ctype_cache[UCHAR_MAX + 1];
/** Initialize the ctype cache. */
static void char_cache_init(void) {
+#if __FreeBSD__ && SANITIZE_MEMORY
+// Work around https://github.com/llvm/llvm-project/issues/65532
+# define bfs_isprint (isprint)
+# define bfs_isspace (isspace)
+#else
+# define bfs_isprint isprint
+# define bfs_isspace isspace
+#endif
+
for (size_t c = 0; c <= UCHAR_MAX; ++c) {
- if (isprint(c)) {
+ if (bfs_isprint(c)) {
ctype_cache[c] |= IS_PRINT;
}
- if (isspace(c)) {
+ if (bfs_isspace(c)) {
ctype_cache[c] |= IS_SPACE;
}
}
@@ -618,11 +628,20 @@ static bool xisprint(unsigned char c, enum wesc_flags flags) {
/** Check if a wide character is printable. */
static bool xiswprint(wchar_t c, enum wesc_flags flags) {
- if (iswprint(c)) {
+#if __FreeBSD__ && SANITIZE_MEMORY
+// Work around https://github.com/llvm/llvm-project/issues/65532
+# define bfs_iswprint (iswprint)
+# define bfs_iswspace (iswspace)
+#else
+# define bfs_iswprint iswprint
+# define bfs_iswspace iswspace
+#endif
+
+ if (bfs_iswprint(c)) {
return true;
}
- if (!(flags & WESC_SHELL) && iswspace(c)) {
+ if (!(flags & WESC_SHELL) && bfs_iswspace(c)) {
return true;
}