raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: raindrops@librelist.org
Subject: [PATCH] linux_inet_diag: annotate memory freeing on diag errors
Date: Sun, 7 Sep 2014 07:12:06 +0000
Message-ID: <20140907071206.GA30143@dcvr.yhbt.net> (raw)
In-Reply-To: <20140907071206.GA30143@dcvr.yhbt.net>

Clarify the code so memory leak alarms in reviewers eyes do not go off.
 ext/raindrops/linux_inet_diag.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
index e4d0fab..773e094 100644
--- a/ext/raindrops/linux_inet_diag.c
+++ b/ext/raindrops/linux_inet_diag.c
@@ -465,12 +465,12 @@ static VALUE diag(void *ptr)
-	{
+	/* prepare to raise, free memory before reacquiring GVL */
+	if (err && args->table) {
 		int save_errno = errno;
-		if (err && args->table) {
-			st_foreach(args->table, st_free_data, 0);
-			st_free_table(args->table);
-		}
+		st_foreach(args->table, st_free_data, 0);
+		st_free_table(args->table);
 		errno = save_errno;
 	return (VALUE)err;
@@ -584,6 +584,10 @@ static void gen_bytecode(struct iovec *iov, union any_addr *inet)
+ * n.b. we may safely raise here because an error will cause diag()
+ * to free args->table
+ */
 static void nl_errcheck(VALUE r)
 	const char *err = (const char *)r;

           reply	other threads:[~2014-09-07  7:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20140907071206.GA30143@dcvr.yhbt.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/raindrops/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140907071206.GA30143@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=raindrops@librelist.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

raindrops RubyGem user+dev discussion/patches/pulls/bugs/help

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/raindrops-public
	git clone --mirror http://ou63pmih66umazou.onion/raindrops-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 raindrops-public raindrops-public/ https://yhbt.net/raindrops-public \
		raindrops-public@yhbt.net raindrops-public@bogomips.org raindrops@librelist.org raindrops@librelist.com
	public-inbox-index raindrops-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git