[PATCH hail] lib/hstor.c: avoid an unconditional leak in append_qparam

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux