[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] Misuse of idn2_free()
From: |
Tim Rühsen |
Subject: |
Re: [Bug-wget] Misuse of idn2_free() |
Date: |
Sat, 08 Apr 2017 17:21:14 +0200 |
User-agent: |
KMail/5.2.3 (Linux/4.9.0-2-amd64; KDE/5.28.0; x86_64; ; ) |
Ups, I was sure that we already reallocate the idn2 memory in iri.c/
idn_encode(), but we don't do that yet.
Could you please try this patch (on top of the current master):
diff --git a/src/iri.c b/src/iri.c
index 2a4da1de..75eaeea6 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -290,6 +290,13 @@ idn_encode (const struct iri *i, const char *host)
xfree (utf8_encoded);
+ if (ret == IDN2_OK && ascii_encoded)
+ {
+ char *tmp = xstrdup (ascii_encoded);
+ idn2_free (ascii_encoded);
+ ascii_encoded = tmp;
+ }
+
return ret == IDN2_OK ? ascii_encoded : NULL;
}
I can also see that idn_decode() can be resurrected with the new libidn2 2.0.0
functionality. I'll do that within the next days.
Regards, Tim
On Samstag, 8. April 2017 11:52:59 CEST Gisle Vanem wrote:
> Tim Rühsen wrote:
> > Thanks, Gisle.
> >
> > pushed with several additional fixes/cleanups regarding idn2.
>
> Too much cleanups I guess since it's crashing because no
> 'idn2_free()' called when needed. This works here:
>
> --- a/url.c 2017-04-08 11:24:21
> +++ b/url.c 2017-04-08 11:38:37
> @@ -944,6 +944,7 @@
> {
> xfree (u->host);
> u->host = new;
> + u->idn_allocated = true;
> host_modified = true;
> }
> }
> @@ -1222,6 +1223,9 @@
> {
> if (url)
> {
> + if (url->idn_allocated)
> + idn2_free (url->host);
> + else
> xfree (url->host);
>
> xfree (url->path);
>
> --- a/url.h 2017-04-08 11:24:21
> +++ b/url.h 2017-04-08 11:35:26
> @@ -84,6 +84,7 @@
> enum url_scheme scheme; /* URL scheme */
>
> char *host; /* Extracted hostname */
> + bool idn_allocated; /* 'host' allocated by libidn2 */
> int port; /* Port number */
>
> -----------
signature.asc
Description: This is a digitally signed message part.