Browse Source

fix undefined pointer comparison in wmemmove

Rich Felker 6 years ago
parent
commit
82c41e9232
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/string/wmemmove.c

+ 2 - 1
src/string/wmemmove.c

@@ -1,9 +1,10 @@
 #include <wchar.h>
+#include <stdint.h>
 
 wchar_t *wmemmove(wchar_t *d, const wchar_t *s, size_t n)
 {
 	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];
 	else
 		while (n--) *d++ = *s++;