Browse Source

fix overrun (n essentially ignored) in wcsncmp

bug report and solution by Richard Pennington
Rich Felker 12 years ago
parent
commit
054ba18599
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/string/wcsncmp.c

+ 1 - 1
src/string/wcsncmp.c

@@ -2,6 +2,6 @@
 
 int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n)
 {
-	for (; n && *l==*r && *l && *r; l++, r++);
+	for (; n && *l==*r && *l && *r; n--, l++, r++);
 	return n ? *l - *r : 0;
 }