diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-26 13:37:16 -0800 |
commit | 11529ecec914d2f0d7575e6d443c2d5a6ff75424 (patch) | |
tree | f91bf9915ab0499913b8ee0e941a642183b7da67 /cache-tree.c | |
parent | Merge branch 'jk/more-comments-on-textconv' (diff) | |
parent | ewah: convert to REALLOC_ARRAY, etc (diff) | |
download | tgif-11529ecec914d2f0d7575e6d443c2d5a6ff75424.tar.xz |
Merge branch 'jk/tighten-alloc'
Update various codepaths to avoid manually-counted malloc().
* jk/tighten-alloc: (22 commits)
ewah: convert to REALLOC_ARRAY, etc
convert ewah/bitmap code to use xmalloc
diff_populate_gitlink: use a strbuf
transport_anonymize_url: use xstrfmt
git-compat-util: drop mempcpy compat code
sequencer: simplify memory allocation of get_message
test-path-utils: fix normalize_path_copy output buffer size
fetch-pack: simplify add_sought_entry
fast-import: simplify allocation in start_packfile
write_untracked_extension: use FLEX_ALLOC helper
prepare_{git,shell}_cmd: use argv_array
use st_add and st_mult for allocation size computation
convert trivial cases to FLEX_ARRAY macros
use xmallocz to avoid size arithmetic
convert trivial cases to ALLOC_ARRAY
convert manual allocations to argv_array
argv-array: add detach function
add helpers for allocating flex-array structs
harden REALLOC_ARRAY and xcalloc against size_t overflow
tree-diff: catch integer overflow in combine_diff_path allocation
...
Diffstat (limited to 'cache-tree.c')
-rw-r--r-- | cache-tree.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c index 20ee7b52df..3ebf9c3aa4 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -79,11 +79,9 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it, ALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc); it->subtree_nr++; - down = xmalloc(sizeof(*down) + pathlen + 1); + FLEX_ALLOC_MEM(down, name, path, pathlen); down->cache_tree = NULL; down->namelen = pathlen; - memcpy(down->name, path, pathlen); - down->name[pathlen] = 0; if (pos < it->subtree_nr) memmove(it->down + pos + 1, |