Skip to content

Commit 9fd0741

Browse files
authored
Merge pull request #7154 from ShiningMassXAcc/fix-C4703
Fix C4703 uninitialized pointer variable warnings
2 parents 6af47d3 + ecc995f commit 9fd0741

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"sarif-viewer.connectToGithubCodeScanning": "off"
3+
}

src/libgit2/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ int git_commit_amend(
340340
{
341341
git_repository *repo;
342342
git_oid tree_id;
343-
git_reference *ref;
343+
git_reference *ref = NULL;
344344
int error;
345345

346346
GIT_ASSERT_ARG(id);

src/libgit2/fetchhead.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int fetchhead_ref_write(
106106
git_fetchhead_ref *fetchhead_ref)
107107
{
108108
char oid[GIT_OID_MAX_HEXSIZE + 1];
109-
const char *type, *name;
109+
const char *type = NULL, *name = NULL;
110110
int head = 0;
111111

112112
GIT_ASSERT_ARG(file);

src/libgit2/index.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ static int read_entry(
25102510
{
25112511
size_t path_length, path_offset, entry_size;
25122512
const char *path_ptr;
2513-
struct entry_common *source_common;
2513+
struct entry_common *source_common = NULL;
25142514
index_entry_short_sha1 source_sha1;
25152515
#ifdef GIT_EXPERIMENTAL_SHA256
25162516
index_entry_short_sha256 source_sha256;
@@ -2862,7 +2862,7 @@ static int write_disk_entry(
28622862
const char *last)
28632863
{
28642864
void *mem = NULL;
2865-
struct entry_common *ondisk_common;
2865+
struct entry_common *ondisk_common = NULL;
28662866
size_t path_len, path_offset, disk_size;
28672867
int varint_len = 0;
28682868
char *path;
@@ -2951,7 +2951,7 @@ static int write_disk_entry(
29512951
path_offset = index_entry_path_offset(index->oid_type, entry->flags);
29522952

29532953
if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) {
2954-
struct entry_common *ondisk_ext;
2954+
struct entry_common *ondisk_ext = NULL;
29552955
uint16_t flags_extended = htons(entry->flags_extended &
29562956
GIT_INDEX_ENTRY_EXTENDED_FLAGS);
29572957

src/libgit2/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static int merge_conflict_resolve_contents(
936936
git_merge_file_result result = {0};
937937
git_merge_driver *driver;
938938
git_merge_driver__builtin builtin = {{0}};
939-
git_index_entry *merge_result;
939+
git_index_entry *merge_result = NULL;
940940
git_odb *odb = NULL;
941941
const char *name;
942942
bool fallback = false;

src/libgit2/repository.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ static int validate_ownership_path(bool *is_safe, const char *path)
682682

683683
static int validate_ownership(git_repository *repo)
684684
{
685-
const char *validation_paths[3] = { NULL }, *path;
685+
const char *validation_paths[3] = { NULL }, *path = NULL;
686686
size_t validation_len = 0, i;
687687
bool is_safe = false;
688688
int error = 0;
@@ -1448,7 +1448,7 @@ int git_repository_config__weakptr(git_config **out, git_repository *repo)
14481448
git_str xdg_buf = GIT_STR_INIT;
14491449
git_str programdata_buf = GIT_STR_INIT;
14501450
bool use_env = repo->use_env;
1451-
git_config *config;
1451+
git_config *config = NULL;
14521452

14531453
if (!(error = config_path_system(&system_buf, use_env)) &&
14541454
!(error = config_path_global(&global_buf, use_env))) {

src/libgit2/transports/httpclient.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static int apply_credentials(
553553
{
554554
git_http_auth_context *auth = server->auth_context;
555555
git_vector *challenges = &server->auth_challenges;
556-
const char *challenge;
556+
const char *challenge = NULL;
557557
git_str token = GIT_STR_INIT;
558558
int error = 0;
559559

src/util/net.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ static int url_parse_authority(
184184
const char *authority,
185185
size_t len)
186186
{
187-
const char *c, *hostport_end, *host_end = NULL,
188-
*userpass_end, *user_end = NULL;
187+
const char *c, *hostport_end = NULL, *host_end = NULL,
188+
*userpass_end = NULL, *user_end = NULL;
189189

190190
enum {
191191
HOSTPORT, HOST, IPV6, HOST_END, USERPASS, USER
@@ -464,7 +464,7 @@ static int url_parse_finalize(git_net_url *url, git_net_url_parser *parser)
464464
int git_net_url_parse(git_net_url *url, const char *given)
465465
{
466466
git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
467-
const char *c, *authority, *path;
467+
const char *c, *authority = NULL, *path = NULL;
468468
size_t authority_len = 0, path_len = 0;
469469
int error = 0;
470470

@@ -574,7 +574,7 @@ int git_net_url_parse_http(
574574
const char *given)
575575
{
576576
git_net_url_parser parser = GIT_NET_URL_PARSER_INIT;
577-
const char *c, *authority, *path = NULL;
577+
const char *c = NULL, *authority = NULL, *path = NULL;
578578
size_t authority_len = 0, path_len = 0;
579579
int error;
580580

@@ -661,7 +661,7 @@ static bool has_at(const char *str)
661661
int git_net_url_parse_scp(git_net_url *url, const char *given)
662662
{
663663
const char *default_port = default_port_for_scheme("ssh");
664-
const char *c, *user, *host, *port = NULL, *path = NULL;
664+
const char *c, *user = NULL, *host = NULL, *port = NULL, *path = NULL;
665665
size_t user_len = 0, host_len = 0, port_len = 0;
666666
unsigned short bracket = 0;
667667

0 commit comments

Comments
 (0)