[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dfa: port to gcc -fsanitize=undefined
From: |
Paul Eggert |
Subject: |
[PATCH] dfa: port to gcc -fsanitize=undefined |
Date: |
Sun, 15 Jan 2017 18:09:05 -0800 |
* lib/dfa.c (copy): Don’t pass NULL with size 0 to memcpy,
as this runs afoul of gcc -fsanitize=undefined.
---
ChangeLog | 6 ++++++
lib/dfa.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f13c784..e0b836b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-15 Paul Eggert <address@hidden>
+
+ dfa: port to gcc -fsanitize=undefined
+ * lib/dfa.c (copy): Don’t pass NULL with size 0 to memcpy,
+ as this runs afoul of gcc -fsanitize=undefined.
+
2017-01-14 Paul Eggert <address@hidden>
strftime: %z is -00 if unknown
diff --git a/lib/dfa.c b/lib/dfa.c
index 5df27ea..f6c3017 100644
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -1999,8 +1999,9 @@ copy (position_set const *src, position_set *dst)
dst->elems = xpalloc (NULL, &dst->alloc, src->nelem - dst->alloc, -1,
sizeof *dst->elems);
}
- memcpy (dst->elems, src->elems, src->nelem * sizeof *dst->elems);
dst->nelem = src->nelem;
+ if (src->nelem != 0)
+ memcpy (dst->elems, src->elems, src->nelem * sizeof *dst->elems);
}
static void
--
2.9.3
- [PATCH] dfa: port to gcc -fsanitize=undefined,
Paul Eggert <=
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Eric Blake, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Paul Eggert, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Kamil Dudka, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Paul Eggert, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Kamil Dudka, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Eric Blake, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Eric Blake, 2017/01/16
- Re: [PATCH] dfa: port to gcc -fsanitize=undefined, Paul Eggert, 2017/01/16