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 ...
This commit is contained in:
@ -8,21 +8,14 @@
|
||||
*/
|
||||
static int normalize_ceiling_entry(struct string_list_item *item, void *unused)
|
||||
{
|
||||
const char *ceil = item->string;
|
||||
int len = strlen(ceil);
|
||||
char buf[PATH_MAX+1];
|
||||
char *ceil = item->string;
|
||||
|
||||
if (len == 0)
|
||||
if (!*ceil)
|
||||
die("Empty path is not supported");
|
||||
if (len > PATH_MAX)
|
||||
die("Path \"%s\" is too long", ceil);
|
||||
if (!is_absolute_path(ceil))
|
||||
die("Path \"%s\" is not absolute", ceil);
|
||||
if (normalize_path_copy(buf, ceil) < 0)
|
||||
if (normalize_path_copy(ceil, ceil) < 0)
|
||||
die("Path \"%s\" could not be normalized", ceil);
|
||||
len = strlen(buf);
|
||||
free(item->string);
|
||||
item->string = xstrdup(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -166,7 +159,7 @@ static struct test_data dirname_data[] = {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
|
||||
char *buf = xmalloc(PATH_MAX + 1);
|
||||
char *buf = xmallocz(strlen(argv[2]));
|
||||
int rv = normalize_path_copy(buf, argv[2]);
|
||||
if (rv)
|
||||
buf = "++failed++";
|
||||
|
Reference in New Issue
Block a user