public inbox for hail-devel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Project Hail <hail-devel@vger.kernel.org>
Subject: [PATCH hail] lib/hstor.c: avoid an unconditional leak in append_qparam
Date: Mon, 27 Sep 2010 10:53:06 +0200	[thread overview]
Message-ID: <87tylbeff1.fsf@meyering.net> (raw)



Signed-off-by: Jim Meyering <meyering@redhat.com>
---
I would have preferred to insert a single line right before the
huri_field_escape call:

    char *v = strdup(val);

[would result in a more compact, single-hunk patch]
but it looks like hail uses the anachronistic (pre-C99)
"declare all vars at outer scope" style, so I conformed.

 lib/hstor.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/hstor.c b/lib/hstor.c
index 6c67bfa..79e0420 100644
--- a/lib/hstor.c
+++ b/lib/hstor.c
@@ -676,6 +676,7 @@ static GString *append_qparam(GString *str, const char *key, const char *val,
 		       char *arg_char)
 {
 	char *stmp;
+	char *v;

 	str = g_string_append(str, arg_char);
 	arg_char[0] = '&';
@@ -683,9 +684,11 @@ static GString *append_qparam(GString *str, const char *key, const char *val,
 	str = g_string_append(str, key);
 	str = g_string_append(str, "=");

-	stmp = huri_field_escape(strdup(val), QUERY_ESCAPE_MASK);
+	v = strdup(val);
+	stmp = huri_field_escape(v, QUERY_ESCAPE_MASK);
 	str = g_string_append(str, stmp);
 	free(stmp);
+	free(v);

 	return str;
 }
--
1.7.3.234.g7bba3

             reply	other threads:[~2010-09-27  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27  8:53 Jim Meyering [this message]
2010-09-27 16:29 ` [PATCH hail] lib/hstor.c: avoid an unconditional leak in append_qparam Pete Zaitcev
2010-09-27 17:05   ` Jim Meyering
2010-09-28  0:23   ` Jeff Garzik
2010-09-27 16:53 ` Jeff Garzik
2010-09-28  0:24   ` Pete Zaitcev

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=87tylbeff1.fsf@meyering.net \
    --to=jim@meyering.net \
    --cc=hail-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox