diff mbox series

[3/6] tr2: stop leaking "thread_name" memory

Message ID patch-3.6-1fa1bbb6743-20210825T231400Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series tr2: plug memory leaks + logic errors + Win32 & Linux feature parity | expand

Commit Message

Ævar Arnfjörð Bjarmason Aug. 25, 2021, 11:19 p.m. UTC
Fix a memory leak introduced in ee4512ed481 (trace2: create new
combined trace facility, 2019-02-22), we were doing a free() of other
memory allocated in tr2tls_create_self(), but not the "thread_name"
"strbuf strbuf".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 trace2/tr2_tls.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Taylor Blau Aug. 26, 2021, 3:09 a.m. UTC | #1
On Thu, Aug 26, 2021 at 01:19:21AM +0200, Ævar Arnfjörð Bjarmason wrote:
> Fix a memory leak introduced in ee4512ed481 (trace2: create new
> combined trace facility, 2019-02-22), we were doing a free() of other
> memory allocated in tr2tls_create_self(), but not the "thread_name"
> "strbuf strbuf".

Your patch is obviously correct, but is "strbuf strbuf" a typo for
"struct strbuf"? It doesn't really matter, and it certainly is not worth
re-submitting 6 patches for a single typo, but just curious.

Thanks,
Taylor
diff mbox series

Patch

diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c
index 067c23755fb..7da94aba522 100644
--- a/trace2/tr2_tls.c
+++ b/trace2/tr2_tls.c
@@ -95,6 +95,7 @@  void tr2tls_unset_self(void)
 
 	pthread_setspecific(tr2tls_key, NULL);
 
+	strbuf_release(&ctx->thread_name);
 	free(ctx->array_us_start);
 	free(ctx);
 }