commit 0784beab029ba53201ef93a601cb8c10d6aaca7f parent 474f2887ce756bb5a14defb25e67b89678be0b8c Author: sin <sin@2f30.org> Date: Thu, 29 Jan 2015 17:55:03 +0000 Allow dest == src in memcpy() memcpy() needs to accept dest == src for gcc. struct foo a, b; a = a; might be implemented using memcpy(). Diffstat:
M | include/string.h | | | 6 | +++--- |
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/string.h b/include/string.h @@ -20,9 +20,9 @@ __fortify_memcpy(void *__restrict dest, const void *__restrict src, size_t n) if (__builtin_constant_p(n) && n > bos) __memcpy_error(); - /* trap if pointers are overlapping */ - if ((d <= s && d + n > s) || - (s <= d && s + n > d)) + /* trap if pointers are overlapping but not if dest == src */ + if ((d < s && d + n > s) || + (s < d && s + n > d)) __builtin_trap(); if (n > bos) __builtin_trap();