소스 검색

fix backwards conditional in stpncpy

this only made the function unnecessarily slow on systems with
unaligned access, but would of course crash on systems that can't do
unaligned accesses (none of which have ports yet).
Rich Felker 14 년 전
부모
커밋
9f19b3ec8d
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/string/stpncpy.c

+ 1 - 1
src/string/stpncpy.c

@@ -14,7 +14,7 @@ char *__stpncpy(char *d, const char *s, size_t n)
 	size_t *wd;
 	const size_t *ws;
 
-	if (((uintptr_t)s & ALIGN) != ((uintptr_t)d & ALIGN)) {
+	if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
 		for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
 		if (!n || !*s) goto tail;
 		wd=(void *)d; ws=(const void *)s;