Re: [PATCH v3] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

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

Re: [PATCH v3] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:09:04

Hui Yiqun [off-list ref] writes:
quoted hunk
According to strbuf.h, strbuf_detach is the sole supported method
to unwrap a memory buffer from its strbuf shell.
...
diff --git a/path.c b/path.c
index 969b494..9801617 100644
--- a/path.c
+++ b/path.c
@@ -625,6 +625,7 @@ const char *enter_repo(const char *path, int strict)
 {
 	static struct strbuf validated_path = STRBUF_INIT;
 	static struct strbuf used_path = STRBUF_INIT;
...
+return_null:
+	free(dbuf);
+	strbuf_release(&used_path);
+	strbuf_release(&validated_path);
 	return NULL;
 }
I see these strbuf's are "static" storage class, so that they do not
have to get freed.

Re: [PATCH v3] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

From: 惠轶群 <hidden>
Date: 2016-06-15 23:09:05

2016-03-29 1:58 GMT+08:00 Junio C Hamano [off-list ref]:
Hui Yiqun [off-list ref] writes:
quoted
According to strbuf.h, strbuf_detach is the sole supported method
to unwrap a memory buffer from its strbuf shell.
...
diff --git a/path.c b/path.c
index 969b494..9801617 100644
--- a/path.c
+++ b/path.c
@@ -625,6 +625,7 @@ const char *enter_repo(const char *path, int strict)
 {
      static struct strbuf validated_path = STRBUF_INIT;
      static struct strbuf used_path = STRBUF_INIT;
...
+return_null:
+     free(dbuf);
+     strbuf_release(&used_path);
+     strbuf_release(&validated_path);
      return NULL;
 }
I see these strbuf's are "static" storage class, so that they do not
have to get freed.
I see, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help