diff options
| author | sin | 2015-01-29 17:55:03 +0000 |
|---|---|---|
| committer | sin | 2015-01-29 17:55:03 +0000 |
| commit | 0784beab029ba53201ef93a601cb8c10d6aaca7f (patch) | |
| tree | 484ccf4fc1c3600b47fae9067cfe4d073e689bcb /include/string.h | |
| parent | 474f2887ce756bb5a14defb25e67b89678be0b8c (diff) | |
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 (limited to '')
| -rw-r--r-- | include/string.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/string.h b/include/string.h index e464eab..21e853e 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -20,9 +20,9 @@ __fortify_memcpy(void *__restrict dest, const void *__restrict src, size_t n) | |||
| 20 | if (__builtin_constant_p(n) && n > bos) | 20 | if (__builtin_constant_p(n) && n > bos) |
| 21 | __memcpy_error(); | 21 | __memcpy_error(); |
| 22 | 22 | ||
| 23 | /* trap if pointers are overlapping */ | 23 | /* trap if pointers are overlapping but not if dest == src */ |
| 24 | if ((d <= s && d + n > s) || | 24 | if ((d < s && d + n > s) || |
| 25 | (s <= d && s + n > d)) | 25 | (s < d && s + n > d)) |
| 26 | __builtin_trap(); | 26 | __builtin_trap(); |
| 27 | if (n > bos) | 27 | if (n > bos) |
| 28 | __builtin_trap(); | 28 | __builtin_trap(); |
