Browse Source

fix undefined pointer comparison in wmemmove

master
Rich Felker 8 years ago
parent
commit
82c41e9232
  1. 3
      src/string/wmemmove.c

3
src/string/wmemmove.c

@ -1,9 +1,10 @@
#include <wchar.h> #include <wchar.h>
#include <stdint.h>
wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n) wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
{ {
wchar_t *d0 = d; wchar_t *d0 = d;
if ((size_t)(d-s) < n) if ((uintptr_t)d-(uintptr_t)s < n * sizeof *d)
while (n--) d[n] = s[n]; while (n--) d[n] = s[n];
else else
while (n--) *d++ = *s++; while (n--) *d++ = *s++;

Loading…
Cancel
Save