Commit Diff


commit - 0f06079ff7426dcffacc14db0c25dc33cf8de601
commit + 14778466f9e410d616fa844c9576ad0d4d1eb84f
blob - 238222eaa7bbed2edf685b5fa98d23dda03063f5
blob + 507b79d036a9965abbb57d877bfe59dec7b2798e
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
@@ -469,14 +469,14 @@ fetch_pack(int fd, int packfd, struct got_object_id *p
 			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;
 			}
 		}