[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file
From: |
Ángel González |
Subject: |
Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file |
Date: |
Mon, 06 Apr 2015 21:25:27 +0200 |
User-agent: |
Thunderbird |
Thanks for your work, Hubert.
I agree it is helpful to name them differently. What about this
alternative rename?
(I'm the host reassignation by using a ternary, plus touched a comment)
diff --git a/src/iri.c b/src/iri.c
index dc1ebd0..eec5646 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -225,19 +225,21 @@ locale_to_utf8 (const char *str)
char *
idn_encode (struct iri *i, char *host)
{
- char *new;
int ret;
+ char *ascii_encoded;
+ char *utf8_encoded = NULL;
/* Encode to UTF-8 if not done */
if (!i->utf8_encode)
{
- if (!remote_to_utf8 (i, (const char *) host, (const char **) &new))
+ if (!remote_to_utf8 (i, (const char *) host, (const char **)
&utf8_encoded))
return NULL; /* Nothing to encode or an error occured */
- host = new;
}
- /* toASCII UTF-8 NULL terminated string */
- ret = idna_to_ascii_8z (host, &new, IDNA_FLAGS);
+ /* Store in ascii_encoded the ASCII UTF-8 NULL terminated string */
+ ret = idna_to_ascii_8z (utf8_encoded ? utf8_encoded : host,
&ascii_encoded, IDNA_FLAGS);
+ xfree (utf8_encoded);
+
if (ret != IDNA_SUCCESS)
{
/* sXXXav : free new when needed ! */
@@ -246,7 +248,7 @@ idn_encode (struct iri *i, char *host)
return NULL;
}
- return new;
+ return ascii_encoded;
}
/* Try to decode an "ASCII encoded" host. Return the new domain in the
locale
- [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Hubert Tarasiuk, 2015/04/06
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Ander Juaristi, 2015/04/06
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file,
Ángel González <=
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Hubert Tarasiuk, 2015/04/06
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Ángel González, 2015/04/06
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Hubert Tarasiuk, 2015/04/08
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Ángel González, 2015/04/08
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Tim Rühsen, 2015/04/10
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Hubert Tarasiuk, 2015/04/11
- Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Tim Rühsen, 2015/04/11
Re: [Bug-wget] Memory leak in idn_encode; Valgrind suppression file, Tim Rühsen, 2015/04/06