]> git.ipfire.org Git - thirdparty/git.git/commitdiff
strvec: use size_t to store nr and alloc
authorJeff King <peff@peff.net>
Sat, 11 Sep 2021 15:01:16 +0000 (11:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 12 Sep 2021 23:25:23 +0000 (16:25 -0700)
We converted argv_array (which later became strvec) to use size_t in
819f0e76b1 (argv-array: use size_t for count and alloc, 2020-07-28) in
order to avoid the possibility of integer overflow. But later, commit
d70a9eb611 (strvec: rename struct fields, 2020-07-28) accidentally
converted these back to ints!

Those two commits were part of the same patch series. I'm pretty sure
what happened is that they were originally written in the opposite order
and then cleaned up and re-ordered during an interactive rebase. And
when resolving the inevitable conflict, I mistakenly took the "rename"
patch completely, accidentally dropping the type change.

We can correct it now; better late than never.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strvec.h

index fdcad75b45b33fdc6974fd35c2102ecbcaba31e4..6b3cbd675895116586407ee4214acfb9b042b33d 100644 (file)
--- a/strvec.h
+++ b/strvec.h
@@ -29,8 +29,8 @@ extern const char *empty_strvec[];
  */
 struct strvec {
        const char **v;
-       int nr;
-       int alloc;
+       size_t nr;
+       size_t alloc;
 };
 
 #define STRVEC_INIT { empty_strvec, 0, 0 }