summaryrefslogtreecommitdiff
path: root/src/array.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-11 11:20:05 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-02-12 22:54:47 -0500
commitec3b4d35f636c26d3c9b5703c3b7f87683800af8 (patch)
treea1d4330c4efaa1b7097f64f4243224e0581a5b2e /src/array.h
parent2884cc42de8b20a58cec8488d014a853d47c047e (diff)
downloadlibgit2-ec3b4d35f636c26d3c9b5703c3b7f87683800af8.tar.gz
Use `size_t` to hold size of arrays
Use `size_t` to hold the size of arrays to ease overflow checking, lest we check for overflow of a `size_t` then promptly truncate by packing the length into a smaller type.
Diffstat (limited to 'src/array.h')
-rw-r--r--src/array.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/array.h b/src/array.h
index 0d0795370..7c4dbdbc1 100644
--- a/src/array.h
+++ b/src/array.h
@@ -23,7 +23,7 @@
*
* typedef git_array_t(my_struct) my_struct_array_t;
*/
-#define git_array_t(type) struct { type *ptr; uint32_t size, asize; }
+#define git_array_t(type) struct { type *ptr; size_t size, asize; }
#define GIT_ARRAY_INIT { NULL, 0, 0 }
@@ -45,7 +45,7 @@ typedef git_array_t(char) git_array_generic_t;
GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
{
volatile git_array_generic_t *a = _a;
- uint32_t new_size;
+ size_t new_size;
char *new_array;
if (a->size < 8) {