[PATCH] get_ref_states: strdup entries and free util in stale list

Subsystems: the rest

DORMANTno replies

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] get_ref_states: strdup entries and free util in stale list

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:47:48

Signed-off-by: Bert Wesarg <redacted>
---
 builtin-remote.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 7916626..bb72e27 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -272,7 +272,9 @@ static int get_ref_states(const struct ref *remote_refs, struct ref_states *stat
 			die("Could not get fetch map for refspec %s",
 				states->remote->fetch_refspec[i]);
 
-	states->new.strdup_strings = states->tracked.strdup_strings = 1;
+	states->new.strdup_strings =
+	states->tracked.strdup_strings =
+	states->stale.strdup_strings = 1;
 	for (ref = fetch_map; ref; ref = ref->next) {
 		unsigned char sha1[20];
 		if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
@@ -768,7 +770,7 @@ static void clear_push_info(void *util, const char *string)
 static void free_remote_ref_states(struct ref_states *states)
 {
 	string_list_clear(&states->new, 0);
-	string_list_clear(&states->stale, 0);
+	string_list_clear(&states->stale, 1);
 	string_list_clear(&states->tracked, 0);
 	string_list_clear(&states->heads, 0);
 	string_list_clear_func(&states->push, clear_push_info);
-- 
1.6.6.rc0.253.g1ec3

Re: [PATCH] get_ref_states: strdup entries and free util in stale list

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:47:48

Hi,

On Tue, 1 Dec 2009, Bert Wesarg wrote:
Signed-off-by: Bert Wesarg <redacted>
Thanks.  I trust you ran the test suite with valgrind just to make sure?

Ciao,
Dscho

Re: [PATCH] get_ref_states: strdup entries and free util in stale list

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:47:48

On Tue, Dec 1, 2009 at 09:35, Johannes Schindelin
[off-list ref] wrote:
Hi,

On Tue, 1 Dec 2009, Bert Wesarg wrote:
quoted
Signed-off-by: Bert Wesarg <redacted>
Thanks.  I trust you ran the test suite with valgrind just to make sure?
Not the test suite. But my use case where I found the problem (Ie.
cut-off branch names) which was 'git remote show <remote>'.
There are still invalid reads of size 4. I think the problem is the
flex array member of 'struct ref' and strlen(). If its worth I can
look into this.

Bert
Ciao,
Dscho

Re: [PATCH] get_ref_states: strdup entries and free util in stale list

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:47:48

On Tue, Dec 1, 2009 at 10:05, Bert Wesarg [off-list ref] wrote:
On Tue, Dec 1, 2009 at 09:35, Johannes Schindelin
quoted
Thanks.  I trust you ran the test suite with valgrind just to make sure?
Not the test suite. But my use case where I found the problem (Ie.
cut-off branch names) which was 'git remote show <remote>'.
There are still invalid reads of size 4. I think the problem is the
flex array member of 'struct ref' and strlen(). If its worth I can
look into this.
I need this new suppression to run the test suite:
diff --git i/t/valgrind/default.supp w/t/valgrind/default.supp
index 9e013fa..39b080a 100644
--- i/t/valgrind/default.supp
+++ w/t/valgrind/default.supp
@@ -43,3 +43,10 @@
        fun:write_buffer
        fun:write_loose_object
 }
+
+{
+       writing-data-from-zlib-triggers-even-more-errors-2
+       Memcheck:Param
+       write(buf)
+       obj:*libpthread-*.so
+}
Bert

Re: [PATCH] get_ref_states: strdup entries and free util in stale list

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:47:48

On Tue, Dec 1, 2009 at 10:05, Bert Wesarg [off-list ref] wrote:
There are still invalid reads of size 4. I think the problem is the
flex array member of 'struct ref' and strlen(). If its worth I can
look into this.
A short heads-up, here is the valgrind error I get for this invalid read:

==27305== Invalid read of size 4
==27305==    at 0x4936AF: copy_ref (remote.c:870)
==27305==    by 0x4942E4: get_fetch_map (remote.c:1271)
==27305==    by 0x44473E: get_remote_ref_states (builtin-remote.c:271)
==27305==    by 0x446DCE: cmd_remote (builtin-remote.c:1022)
==27305==    by 0x4045F0: handle_internal_command (git.c:257)
==27305==    by 0x404B8F: main (git.c:482)
==27305==  Address 0x5b5ba38 is 104 bytes inside a block of size 107 alloc'd
==27305==    at 0x4C24477: calloc (vg_replace_malloc.c:418)
==27305==    by 0x4B09AD: xcalloc (wrapper.c:75)
==27305==    by 0x493924: alloc_ref_with_prefix (remote.c:853)
==27305==    by 0x46653B: get_remote_heads (connect.c:96)
==27305==    by 0x4A9347: get_refs_via_connect (transport.c:453)
==27305==    by 0x4A7F14: transport_get_remote_refs (transport.c:895)
==27305==    by 0x4445B6: get_remote_ref_states (builtin-remote.c:810)
==27305==    by 0x446DCE: cmd_remote (builtin-remote.c:1022)
==27305==    by 0x4045F0: handle_internal_command (git.c:257)
==27305==    by 0x404B8F: main (git.c:482)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help