mirror of
https://github.com/mirror/wget.git
synced 2025-01-31 14:50:23 +08:00
idn: use idn_free() to free allocated libidn memory
xfree() might crash on libidn memory on Windows. From 'man idn_free': "Under Windows, different parts of the same application may use different heap memory, and then it is important to deallocate memory allocated within the same module that allocated it. This function makes that possible."
This commit is contained in:
parent
3d8e765c1d
commit
9df2250f4c
@ -54,6 +54,11 @@ as that of the covered work. */
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef ENABLE_IRI
|
||||
#include <idn-free.h>
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "host.h"
|
||||
#include "connect.h"
|
||||
@ -278,7 +283,7 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
|
||||
str = xmalloc (len);
|
||||
snprintf (str, len, "%s (%s)", name, print);
|
||||
str[len-1] = '\0';
|
||||
xfree (name);
|
||||
idn_free (name);
|
||||
}
|
||||
|
||||
logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "),
|
||||
|
@ -57,6 +57,10 @@ as that of the covered work. */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef ENABLE_IRI
|
||||
#include <idn-free.h>
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "host.h"
|
||||
#include "url.h"
|
||||
@ -741,7 +745,7 @@ lookup_host (const char *host, int flags)
|
||||
str = xmalloc (len);
|
||||
snprintf (str, len, "%s (%s)", name, host);
|
||||
str[len-1] = '\0';
|
||||
xfree (name);
|
||||
idn_free (name);
|
||||
}
|
||||
|
||||
logprintf (LOG_VERBOSE, _("Resolving %s... "),
|
||||
|
@ -35,6 +35,7 @@ as that of the covered work. */
|
||||
#include <iconv.h>
|
||||
#include <stringprep.h>
|
||||
#include <idna.h>
|
||||
#include <idn-free.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
@ -39,6 +39,9 @@ struct iri {
|
||||
|
||||
#ifdef ENABLE_IRI
|
||||
|
||||
# include <idna.h>
|
||||
# include <idn-free.h>
|
||||
|
||||
char *parse_charset (char *str);
|
||||
char *find_locale (void);
|
||||
bool check_encoding_name (char *encoding);
|
||||
@ -62,6 +65,7 @@ extern struct iri dummy_iri;
|
||||
#define locale_to_utf8(str) (str)
|
||||
#define idn_encode(a,b) NULL
|
||||
#define idn_decode(str) NULL
|
||||
#define idn_free(str) ((void)0)
|
||||
#define remote_to_utf8(a,b,c) false
|
||||
#define iri_new() (&dummy_iri)
|
||||
#define iri_dup(a) (&dummy_iri)
|
||||
|
@ -897,6 +897,7 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -1175,7 +1176,13 @@ url_free (struct url *url)
|
||||
{
|
||||
if (url)
|
||||
{
|
||||
xfree (url->host);
|
||||
if (url->idn_allocated) {
|
||||
idn_free (url->host); /* A dummy if !defined(ENABLE_IRI) */
|
||||
url->host = NULL;
|
||||
}
|
||||
else
|
||||
xfree (url->host);
|
||||
|
||||
xfree (url->path);
|
||||
xfree (url->url);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user