Fix use of idn2_free()

* src/connect.c (connect_to_ip): Use xfree() instead of idn2_free()
* src/host.c (lookup_host): Use xfree() instead of idn2_free()
* src/iri.h: Do not include idn2.h
* src/url.c (url_free): Use xfree() instead of idn2_free()
* src/url.h (struct url): Remove 'idn_allocated' from struct

Reported-by: Gisle Vanem
This commit is contained in:
Tim Rühsen 2017-04-08 11:05:55 +02:00
parent 7ffe93cabb
commit 6ef493b19e
5 changed files with 5 additions and 31 deletions

View File

@ -56,10 +56,6 @@ as that of the covered work. */
#include <string.h>
#include <sys/time.h>
#ifdef ENABLE_IRI
#include <idn2.h>
#endif
#include "utils.h"
#include "host.h"
#include "connect.h"
@ -280,11 +276,8 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
if (opt.enable_iri && (name = idn_decode ((char *) print)) != NULL)
{
int len = strlen (print) + strlen (name) + 4;
str = xmalloc (len);
snprintf (str, len, "%s (%s)", name, print);
str[len-1] = '\0';
idn2_free (name);
str = aprintf ("%s (%s)", name, print);
xfree (name);
}
logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "),

View File

@ -57,10 +57,6 @@ as that of the covered work. */
#include <errno.h>
#ifdef ENABLE_IRI
#include <idn2.h>
#endif
#include "utils.h"
#include "host.h"
#include "url.h"
@ -846,11 +842,8 @@ lookup_host (const char *host, int flags)
if (opt.enable_iri && (name = idn_decode ((char *) host)) != NULL)
{
int len = strlen (host) + strlen (name) + 4;
str = xmalloc (len);
snprintf (str, len, "%s (%s)", name, host);
str[len-1] = '\0';
idn2_free (name);
str = aprintf ("%s (%s)", name, host);
xfree (name);
}
logprintf (LOG_VERBOSE, _("Resolving %s... "),

View File

@ -40,8 +40,6 @@ struct iri {
#ifdef ENABLE_IRI
# include <idn2.h>
char *parse_charset (const char *str);
const char *find_locale (void);
bool check_encoding_name (const char *encoding);

View File

@ -944,7 +944,6 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
{
xfree (u->host);
u->host = new;
u->idn_allocated = true;
host_modified = true;
}
}
@ -1223,12 +1222,7 @@ url_free (struct url *url)
{
if (url)
{
if (url->idn_allocated) {
idn2_free (url->host); /* A dummy if !defined(ENABLE_IRI) */
url->host = NULL;
}
else
xfree (url->host);
xfree (url->host);
xfree (url->path);
xfree (url->url);

View File

@ -99,10 +99,6 @@ struct url
/* Username and password (unquoted). */
char *user;
char *passwd;
/* 'host' is allocated by idn2_lookup_u8() via idn_encode().
* Call 'idn2_free()' to free this memory. */
bool idn_allocated;
};
/* Function declarations */