Unverified Commit db729803 by Edward Thomson Committed by GitHub

Merge pull request #6018 from libgit2/ethomson/fixups

Fixes from code analysis
parents 969a056c ed0ea96e
...@@ -722,7 +722,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm ...@@ -722,7 +722,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
while (tl->type) { while (tl->type) {
size_t len = strlen(tl->type); size_t len = strlen(tl->type);
if (match_string(date, tl->type) >= len-1) { if (match_string(date, tl->type) >= len-1) {
update_tm(tm, now, tl->length * *num); update_tm(tm, now, tl->length * (unsigned long)*num);
*num = 0; *num = 0;
*touched = 1; *touched = 1;
return end; return end;
......
...@@ -107,11 +107,6 @@ int git_error_set_str(int error_class, const char *string) ...@@ -107,11 +107,6 @@ int git_error_set_str(int error_class, const char *string)
GIT_ASSERT_ARG(string); GIT_ASSERT_ARG(string);
if (!string) {
git_error_set(GIT_ERROR_INVALID, "unspecified caller error");
return -1;
}
git_buf_clear(buf); git_buf_clear(buf);
git_buf_puts(buf, string); git_buf_puts(buf, string);
......
...@@ -206,6 +206,7 @@ int git_filter_global_init(void) ...@@ -206,6 +206,7 @@ int git_filter_global_init(void)
GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0) GIT_FILTER_IDENT, ident, GIT_FILTER_IDENT_PRIORITY) < 0)
error = -1; error = -1;
if (!error)
error = git_runtime_shutdown_register(git_filter_global_shutdown); error = git_runtime_shutdown_register(git_filter_global_shutdown);
done: done:
......
...@@ -286,8 +286,10 @@ int git_hashsig_create_fromfile( ...@@ -286,8 +286,10 @@ int git_hashsig_create_fromfile(
return fd; return fd;
} }
if ((error = hashsig_in_progress_init(&prog, sig)) < 0) if ((error = hashsig_in_progress_init(&prog, sig)) < 0) {
p_close(fd);
return error; return error;
}
while (!error) { while (!error) {
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) { if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
......
...@@ -714,8 +714,10 @@ static int midx_write( ...@@ -714,8 +714,10 @@ static int midx_write(
error = git_vector_init(&object_entries, git_array_size(object_entries_array), object_entry__cmp); error = git_vector_init(&object_entries, git_array_size(object_entries_array), object_entry__cmp);
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
git_array_foreach (object_entries_array, i, entry) git_array_foreach (object_entries_array, i, entry) {
error = git_vector_set(NULL, &object_entries, i, entry); if ((error = git_vector_set(NULL, &object_entries, i, entry)) < 0)
goto cleanup;
}
git_vector_set_sorted(&object_entries, 0); git_vector_set_sorted(&object_entries, 0);
git_vector_sort(&object_entries); git_vector_sort(&object_entries);
git_vector_uniq(&object_entries, NULL); git_vector_uniq(&object_entries, NULL);
...@@ -751,10 +753,12 @@ static int midx_write( ...@@ -751,10 +753,12 @@ static int midx_write(
goto cleanup; goto cleanup;
if (entry->offset >= 0x80000000l) { if (entry->offset >= 0x80000000l) {
word = htonl(0x80000000u | object_large_offsets_count++); word = htonl(0x80000000u | object_large_offsets_count++);
error = write_offset(entry->offset, midx_write_buf, &object_large_offsets); if ((error = write_offset(entry->offset, midx_write_buf, &object_large_offsets)) < 0)
goto cleanup;
} else { } else {
word = htonl((uint32_t)entry->offset & 0x7fffffffu); word = htonl((uint32_t)entry->offset & 0x7fffffffu);
} }
error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word)); error = git_buf_put(&object_offsets, (const char *)&word, sizeof(word));
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
......
...@@ -1298,7 +1298,12 @@ int git_pack_foreach_entry( ...@@ -1298,7 +1298,12 @@ int git_pack_foreach_entry(
return error; return error;
} }
GIT_ASSERT(p->index_map.data); if (!p->index_map.data) {
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->index_map.data == NULL");
git_mutex_unlock(&p->lock);
return -1;
}
index = p->index_map.data; index = p->index_map.data;
if (p->index_version > 1) if (p->index_version > 1)
...@@ -1387,7 +1392,11 @@ int git_pack_foreach_entry_offset( ...@@ -1387,7 +1392,11 @@ int git_pack_foreach_entry_offset(
if ((error = pack_index_open_locked(p)) < 0) if ((error = pack_index_open_locked(p)) < 0)
goto cleanup; goto cleanup;
GIT_ASSERT(p->index_map.data); if (!p->index_map.data) {
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->index_map.data == NULL");
goto cleanup;
}
index = p->index_map.data; index = p->index_map.data;
} }
...@@ -1479,7 +1488,11 @@ static int pack_entry_find_offset( ...@@ -1479,7 +1488,11 @@ static int pack_entry_find_offset(
if ((error = pack_index_open_locked(p)) < 0) if ((error = pack_index_open_locked(p)) < 0)
goto cleanup; goto cleanup;
GIT_ASSERT(p->index_map.data); if (!p->index_map.data) {
git_error_set(GIT_ERROR_INTERNAL, "internal error: p->index_map.data == NULL");
goto cleanup;
}
index = p->index_map.data; index = p->index_map.data;
level1_ofs = p->index_map.data; level1_ofs = p->index_map.data;
......
...@@ -598,7 +598,6 @@ static int apply_credentials( ...@@ -598,7 +598,6 @@ static int apply_credentials(
} else if (!token.size) { } else if (!token.size) {
git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challenge"); git_error_set(GIT_ERROR_HTTP, "failed to respond to authentication challenge");
error = GIT_EAUTH; error = GIT_EAUTH;
error = -1;
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