Commit 7e53e8ce by Edward Thomson Committed by GitHub

Merge pull request #4167 from pks-t/pks/ci-fixes

Coverity fixes
parents 69d0b460 e7330016
...@@ -478,14 +478,15 @@ cleanup: ...@@ -478,14 +478,15 @@ cleanup:
* The blobs of origin and porigin exactly match, so everything origin is * The blobs of origin and porigin exactly match, so everything origin is
* suspected for can be blamed on the parent. * suspected for can be blamed on the parent.
*/ */
static void pass_whole_blame(git_blame *blame, static int pass_whole_blame(git_blame *blame,
git_blame__origin *origin, git_blame__origin *porigin) git_blame__origin *origin, git_blame__origin *porigin)
{ {
git_blame__entry *e; git_blame__entry *e;
if (!porigin->blob) if (!porigin->blob &&
git_object_lookup((git_object**)&porigin->blob, blame->repository, git_object_lookup((git_object**)&porigin->blob, blame->repository,
git_blob_id(origin->blob), GIT_OBJ_BLOB); git_blob_id(origin->blob), GIT_OBJ_BLOB) < 0)
return -1;
for (e=blame->ent; e; e=e->next) { for (e=blame->ent; e; e=e->next) {
if (!same_suspect(e->suspect, origin)) if (!same_suspect(e->suspect, origin))
continue; continue;
...@@ -493,6 +494,8 @@ static void pass_whole_blame(git_blame *blame, ...@@ -493,6 +494,8 @@ static void pass_whole_blame(git_blame *blame,
origin_decref(e->suspect); origin_decref(e->suspect);
e->suspect = porigin; e->suspect = porigin;
} }
return 0;
} }
static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
...@@ -543,7 +546,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt) ...@@ -543,7 +546,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
} }
if (porigin->blob && origin->blob && if (porigin->blob && origin->blob &&
!git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) { !git_oid_cmp(git_blob_id(porigin->blob), git_blob_id(origin->blob))) {
pass_whole_blame(blame, origin, porigin); error = pass_whole_blame(blame, origin, porigin);
goto finish;
origin_decref(porigin); origin_decref(porigin);
goto finish; goto finish;
} }
......
...@@ -1041,8 +1041,9 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con ...@@ -1041,8 +1041,9 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len);
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2);
git_buf_grow(&buf, alloc_len); if (git_buf_grow(&buf, alloc_len) < 0 ||
git_buf_printf(&buf, "%s.", base_name); git_buf_printf(&buf, "%s.", base_name) < 0)
goto end_parse;
rpos = 0; rpos = 0;
...@@ -1082,6 +1083,11 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con ...@@ -1082,6 +1083,11 @@ static int parse_section_header_ext(struct reader *reader, const char *line, con
} while (line + rpos < last_quote); } while (line + rpos < last_quote);
end_parse: end_parse:
if (git_buf_oom(&buf)) {
git_buf_free(&buf);
return -1;
}
if (line[rpos] != '"' || line[rpos + 1] != ']') { if (line[rpos] != '"' || line[rpos + 1] != ']') {
set_parse_error(reader, rpos, "Unexpected text after closing quotes"); set_parse_error(reader, rpos, "Unexpected text after closing quotes");
git_buf_free(&buf); git_buf_free(&buf);
......
...@@ -44,7 +44,11 @@ static git_diff_parsed *diff_parsed_alloc(void) ...@@ -44,7 +44,11 @@ static git_diff_parsed *diff_parsed_alloc(void)
diff->base.patch_fn = git_patch_parsed_from_diff; diff->base.patch_fn = git_patch_parsed_from_diff;
diff->base.free_fn = diff_parsed_free; diff->base.free_fn = diff_parsed_free;
git_diff_init_options(&diff->base.opts, GIT_DIFF_OPTIONS_VERSION); if (git_diff_init_options(&diff->base.opts, GIT_DIFF_OPTIONS_VERSION) < 0) {
git__free(&diff);
return NULL;
}
diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE; diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE;
git_pool_init(&diff->base.pool, 1); git_pool_init(&diff->base.pool, 1);
......
...@@ -428,7 +428,7 @@ static int pack_backend__read_prefix( ...@@ -428,7 +428,7 @@ static int pack_backend__read_prefix(
git_oid_cpy(out_oid, short_oid); git_oid_cpy(out_oid, short_oid);
} else { } else {
struct git_pack_entry e; struct git_pack_entry e;
git_rawobj raw; git_rawobj raw = {NULL};
if ((error = pack_entry_find_prefix( if ((error = pack_entry_find_prefix(
&e, (struct pack_backend *)backend, short_oid, len)) == 0 && &e, (struct pack_backend *)backend, short_oid, len)) == 0 &&
......
...@@ -66,7 +66,7 @@ static void shutdown_ssl_locking(void) ...@@ -66,7 +66,7 @@ static void shutdown_ssl_locking(void)
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for (i = 0; i < num_locks; ++i) for (i = 0; i < num_locks; ++i)
git_mutex_free(openssl_locks); git_mutex_free(&openssl_locks[i]);
git__free(openssl_locks); git__free(openssl_locks);
} }
......
...@@ -444,9 +444,9 @@ static int parse_header_git( ...@@ -444,9 +444,9 @@ static int parse_header_git(
goto done; goto done;
parse_advance_ws(ctx); parse_advance_ws(ctx);
parse_advance_expected_str(ctx, "\n");
if (ctx->line_len > 0) { if (parse_advance_expected_str(ctx, "\n") < 0 ||
ctx->line_len > 0) {
error = parse_err("trailing data at line %"PRIuZ, ctx->line_num); error = parse_err("trailing data at line %"PRIuZ, ctx->line_num);
goto done; goto done;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment