Commit 14778466f9e410d616fa844c9576ad0d4d1eb84f

Stefan Sperling 2020-03-18T16:11:29

realloc(p, nmemb * size) -> reallocarray(p, nmemb, size)

diff --git a/libexec/got-fetch-pack/got-fetch-pack.c b/libexec/got-fetch-pack/got-fetch-pack.c
index 238222e..507b79d 100644
--- a/libexec/got-fetch-pack/got-fetch-pack.c
+++ b/libexec/got-fetch-pack/got-fetch-pack.c
@@ -469,14 +469,14 @@ fetch_pack(int fd, int packfd, struct got_object_id *packid,
 			continue;
 		if (refsz == nref + 1) {
 			refsz *= 2;
-			have = realloc(have, refsz * sizeof(have[0]));
+			have = reallocarray(have, refsz, sizeof(have[0]));
 			if (have == NULL) {
-				err = got_error_from_errno("realloc");
+				err = got_error_from_errno("reallocarray");
 				goto done;
 			}
-			want = realloc(want, refsz * sizeof(want[0]));
+			want = reallocarray(want, refsz, sizeof(want[0]));
 			if (want == NULL) {
-				err = got_error_from_errno("realloc");
+				err = got_error_from_errno("reallocarray");
 				goto done;
 			}
 		}