Fix a few valgrind errors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/src/config.c b/src/config.c
index 4fb1611..571a1f9 100644
--- a/src/config.c
+++ b/src/config.c
@@ -436,7 +436,7 @@ int git_config_get_bool(int *out, git_config *cfg, const char *name)
int git_config_get_string(const char **out, git_config *cfg, const char *name)
{
int ret;
- const char *str;
+ const char *str = NULL;
if ((ret = get_string(&str, cfg, name)) < 0)
return ret;
diff --git a/src/index.c b/src/index.c
index 5a35329..007f19a 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1098,7 +1098,8 @@ static int read_reuc(git_index *index, const char *buffer, size_t size)
size_t len;
int i;
- if (git_vector_init(&index->reuc, 16, reuc_cmp) < 0)
+ /* This gets called multiple times, the vector might already be initialized */
+ if (index->reuc._alloc_size == 0 && git_vector_init(&index->reuc, 16, reuc_cmp) < 0)
return -1;
while (size) {
diff --git a/src/transports/local.c b/src/transports/local.c
index 84acc79..587b55b 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -227,6 +227,8 @@ static int local_negotiate_fetch(
git_oid_cpy(&rhead->loid, git_object_id(obj));
else if (error != GIT_ENOTFOUND)
return error;
+ else
+ memset(&rhead->loid, 0, sizeof(git_oid));
git_object_free(obj);
giterr_clear();
}