sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [PATCH] free buffer if pthread_setspecific fails
@ 2017-03-16 19:45 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-03-16 19:45 UTC (permalink / raw)
  To: sleepy-penguin

Unlikely, but we must not leak memory if pthread_setspecific
somehow fails.
---
 ext/sleepy_penguin/init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c
index 01bb52f..f9671eb 100644
--- a/ext/sleepy_penguin/init.c
+++ b/ext/sleepy_penguin/init.c
@@ -113,6 +113,7 @@ void *rb_sp_gettlsbuf(size_t *size)
 	buf->capa = *size;
 	err = pthread_setspecific(rb_sp_key, buf);
 	if (err != 0) {
+		free(buf);
 		errno = err;
 		rb_sys_fail("BUG: pthread_setspecific");
 	}
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-16 19:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 19:45 [PATCH] free buffer if pthread_setspecific fails Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/sleepy_penguin.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).