Bladeren bron

Fix up memset() argument ordering in open_memstream(). Previously
parts of the buffers were not being zeroed out as expected. Reported
by Dmytro Gorbunov <dmitro.gorbunov@gmail.com>.

Paul Mundt 15 jaren geleden
bovenliggende
commit
8c5150190e
1 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 2 2
      libc/stdio/open_memstream.c

+ 2 - 2
libc/stdio/open_memstream.c

@@ -97,7 +97,7 @@ static int oms_seek(register void *cookie, __offmax_t *pos, int whence)
 		if (buf) {
 			*COOKIE->bufloc = COOKIE->buf = buf;
 			COOKIE->len = leastlen;
-			memset(buf + COOKIE->eof, leastlen - COOKIE->eof, 0); /* 0-fill */
+			memset(buf + COOKIE->eof, 0, leastlen - COOKIE->eof); /* 0-fill */
 		} else {
 			/* TODO: check glibc errno setting... */
 			return -1;
@@ -107,7 +107,7 @@ static int oms_seek(register void *cookie, __offmax_t *pos, int whence)
 	*pos = COOKIE->pos = --leastlen;
 
 	if (leastlen > COOKIE->eof) {
-		memset(COOKIE->buf + COOKIE->eof, leastlen - COOKIE->eof, 0);
+		memset(COOKIE->buf + COOKIE->eof, 0, leastlen - COOKIE->eof);
 		*COOKIE->sizeloc = COOKIE->eof;
 	}