Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions builtin/fsmonitor--daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,8 @@ static int fsmonitor_run_daemon(void)
err = fsmonitor_run_daemon_1(&state);

done:
fsmonitor_free_token_data(state.current_token_data);
state.current_token_data = NULL;
pthread_cond_destroy(&state.cookies_cond);
pthread_mutex_destroy(&state.main_lock);
{
Expand Down
7 changes: 5 additions & 2 deletions builtin/worktree.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,17 @@ static int add(int ac, const char **av, const char *prefix,
strvec_push(&cp.args, branch);
if (opt_track)
strvec_push(&cp.args, opt_track);
if (run_command(&cp))
return -1;
if (run_command(&cp)) {
ret = -1;
goto cleanup;
}
branch = new_branch;
} else if (opt_track) {
die(_("--[no-]track can only be used if a new branch is created"));
}

ret = add_worktree(path, branch, &opts);
cleanup:
free(path);
free(opt_track);
free(branch_to_free);
Expand Down
2 changes: 1 addition & 1 deletion bundle-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static int download_https_uri_to_file(const char *file, const char *uri)
if (child_in)
fclose(child_in);
if (finish_command(&cp))
return 1;
result = 1;
if (child_out)
fclose(child_out);
return result;
Expand Down
4 changes: 1 addition & 3 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2269,10 +2269,8 @@ int mingw_kill(pid_t pid, int sig)
}
ret = terminate_process_tree(h, 128 + sig);
}
if (ret) {
if (ret)
errno = err_win_to_posix(GetLastError());
CloseHandle(h);
}
return ret;
} else if (pid > 0 && sig == 0) {
HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
Expand Down
1 change: 1 addition & 0 deletions compat/win32/exit-process.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ static int exit_process(HANDLE process, int exit_code)
return terminate_process_tree(process, exit_code);
}

CloseHandle(process);
return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion diff-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
continue;

if (ce_stage(ce)) {
struct combine_diff_path *dpath;
struct combine_diff_path *dpath = NULL;
struct diff_filepair *pair;
unsigned int wt_mode = 0;
int num_compare_stages = 0;
Expand All @@ -164,6 +164,7 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
else {
if (changed < 0) {
perror(ce->name);
free(dpath);
continue;
}
wt_mode = 0;
Expand Down
9 changes: 7 additions & 2 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3792,13 +3792,18 @@ static int read_one_dir(struct untracked_cache_dir **untracked_,
ALLOC_ARRAY(ud.untracked, ud.untracked_nr);

ud.dirs_alloc = ud.dirs_nr = decode_varint(&data);
if (data > end)
if (data > end) {
free(ud.untracked);
return -1;
}
ALLOC_ARRAY(ud.dirs, ud.dirs_nr);

eos = memchr(data, '\0', end - data);
if (!eos || eos == end)
if (!eos || eos == end) {
free(ud.untracked);
free(ud.dirs);
return -1;
}

*untracked_ = untracked = xmalloc(st_add3(sizeof(*untracked), eos - data, 1));
memcpy(untracked, &ud, sizeof(ud));
Expand Down
1 change: 1 addition & 0 deletions imap-send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,7 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,

curl_easy_cleanup(curl);
curl_global_cleanup();
strbuf_release(&msgbuf.buf);

if (cred.username) {
if (res == CURLE_OK)
Expand Down
3 changes: 1 addition & 2 deletions line-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,7 @@ int line_log_process_ranges_arbitrary_commit(struct rev_info *rev, struct commit

if (range) {
if (commit->parents && !bloom_filter_check(rev, commit, range)) {
struct line_log_data *prange = line_log_data_copy(range);
add_line_range(rev, commit->parents->item, prange);
add_line_range(rev, commit->parents->item, range);
clear_commit_line_range(rev, commit);
} else if (commit->parents && commit->parents->next)
changed = process_ranges_merge_commit(rev, commit, range);
Expand Down
11 changes: 6 additions & 5 deletions loose.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source_
{
struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;
FILE *fp;
int ret = -1;

if (!loose->map)
loose_object_map_init(&loose->map);
Expand Down Expand Up @@ -98,13 +99,12 @@ static int load_one_loose_object_map(struct repository *repo, struct odb_source_
insert_loose_map(loose, &oid, &compat_oid);
}

strbuf_release(&buf);
strbuf_release(&path);
return errno ? -1 : 0;
ret = 0;
err:
fclose(fp);
strbuf_release(&buf);
strbuf_release(&path);
return -1;
return ret;
}

int repo_read_loose_object_map(struct repository *repo)
Expand Down Expand Up @@ -202,7 +202,8 @@ static int write_one_object(struct odb_source_loose *loose,
return 0;
errout:
error_errno(_("failed to write loose object index %s"), path.buf);
close(fd);
if (fd >= 0)
close(fd);
rollback_lock_file(&lock);
strbuf_release(&buf);
strbuf_release(&path);
Expand Down
4 changes: 4 additions & 0 deletions reftable/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ static int reftable_table_refs_for_unindexed(struct reftable_table *t,
if (ti)
table_iter_close(ti);
reftable_free(ti);
if (filter) {
reftable_buf_release(&filter->oid);
reftable_free(filter);
}
}
return err;
}
Expand Down
6 changes: 3 additions & 3 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ int start_command(struct child_process *cmd)
failed_errno = errno;
if (need_in)
close_pair(fdin);
else if (cmd->in)
else if (cmd->in > 0)
close(cmd->in);
str = "standard output";
goto fail_pipe;
Expand All @@ -720,11 +720,11 @@ int start_command(struct child_process *cmd)
failed_errno = errno;
if (need_in)
close_pair(fdin);
else if (cmd->in)
else if (cmd->in > 0)
close(cmd->in);
if (need_out)
close_pair(fdout);
else if (cmd->out)
else if (cmd->out > 0)
close(cmd->out);
str = "standard error";
fail_pipe:
Expand Down
8 changes: 6 additions & 2 deletions submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,10 +2627,10 @@ int get_superproject_working_tree(struct strbuf *buf)
* We might have a superproject, but it is harder
* to determine.
*/
return 0;
goto out;

if (!strbuf_realpath(&one_up, "../", 0))
return 0;
goto out;

subpath = relative_path(cwd, one_up.buf, &sb);
strbuf_release(&one_up);
Expand Down Expand Up @@ -2693,6 +2693,10 @@ int get_superproject_working_tree(struct strbuf *buf)
die(_("ls-tree returned unexpected return code %d"), code);

return ret;

out:
free(cwd);
return 0;
}

/*
Expand Down
Loading