mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Replaced xfree_null() by xfree() and nullify argument after freeing.
This commit is contained in:
parent
d9325f5db5
commit
4850e9c873
@ -1,3 +1,12 @@
|
||||
2014-11-29 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* utils.h: xfree() sets argument to NULL after freeing,
|
||||
removed xfree_null()
|
||||
* connect.c, cookies.c, ftp-basic.c, ftp-ls.c, ftp.c hash.c,
|
||||
host.c, html-url.c, http.c, init.c, iri.c, log.c, main.c,
|
||||
mswindows.c, netrc.c, openssl.c, recur.c, res.c, retr.c,
|
||||
url.c, warc.c: Replaced xfree_null() by xfree()
|
||||
|
||||
2014-11-28 Tim Ruehsen <tim.ruehsen@gmx.de>
|
||||
|
||||
* main.c: Fix length of program_argstring,
|
||||
|
@ -284,8 +284,7 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
|
||||
logprintf (LOG_VERBOSE, _("Connecting to %s|%s|:%d... "),
|
||||
str ? str : escnonprint_uri (print), txt_addr, port);
|
||||
|
||||
if (str)
|
||||
xfree (str);
|
||||
xfree (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -153,10 +153,10 @@ cookie_expired_p (const struct cookie *c)
|
||||
static void
|
||||
delete_cookie (struct cookie *cookie)
|
||||
{
|
||||
xfree_null (cookie->domain);
|
||||
xfree_null (cookie->path);
|
||||
xfree_null (cookie->attr);
|
||||
xfree_null (cookie->value);
|
||||
xfree (cookie->domain);
|
||||
xfree (cookie->path);
|
||||
xfree (cookie->attr);
|
||||
xfree (cookie->value);
|
||||
xfree (cookie);
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ parse_set_cookie (const char *set_cookie, bool silent)
|
||||
{
|
||||
if (!TOKEN_NON_EMPTY (value))
|
||||
goto error;
|
||||
xfree_null (cookie->domain);
|
||||
xfree (cookie->domain);
|
||||
/* Strictly speaking, we should set cookie->domain_exact if the
|
||||
domain doesn't begin with a dot. But many sites set the
|
||||
domain to "foo.com" and expect "subhost.foo.com" to get the
|
||||
@ -389,7 +389,7 @@ parse_set_cookie (const char *set_cookie, bool silent)
|
||||
{
|
||||
if (!TOKEN_NON_EMPTY (value))
|
||||
goto error;
|
||||
xfree_null (cookie->path);
|
||||
xfree (cookie->path);
|
||||
cookie->path = strdupdelim (value.b, value.e);
|
||||
}
|
||||
else if (TOKEN_IS (name, "expires"))
|
||||
|
@ -1136,7 +1136,7 @@ ftp_pwd (int csock, char **pwd)
|
||||
goto err;
|
||||
|
||||
/* Has the `pwd' been already allocated? Free! */
|
||||
xfree_null (*pwd);
|
||||
xfree (*pwd);
|
||||
|
||||
*pwd = xstrdup (request);
|
||||
|
||||
|
@ -363,8 +363,8 @@ ftp_parse_unix_ls (const char *file, int ignore_perms)
|
||||
if (error || ignore)
|
||||
{
|
||||
DEBUGP (("Skipping.\n"));
|
||||
xfree_null (cur.name);
|
||||
xfree_null (cur.linkto);
|
||||
xfree (cur.name);
|
||||
xfree (cur.linkto);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1089,7 +1089,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
|
||||
else
|
||||
upwd = concat_strings (tmpu, "@", (char *) 0);
|
||||
xfree (tmpu);
|
||||
xfree_null (tmpp);
|
||||
xfree (tmpp);
|
||||
}
|
||||
else
|
||||
upwd = xstrdup ("");
|
||||
|
12
src/ftp.c
12
src/ftp.c
@ -449,7 +449,7 @@ Error in server response, closing control connection.\n"));
|
||||
return err;
|
||||
case FTPSRVERR :
|
||||
/* PWD unsupported -- assume "/". */
|
||||
xfree_null (con->id);
|
||||
xfree (con->id);
|
||||
con->id = xstrdup ("/");
|
||||
break;
|
||||
case FTPOK:
|
||||
@ -1703,7 +1703,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
|
||||
if (err == FOPEN_EXCL_ERR)
|
||||
{
|
||||
/* Re-determine the file name. */
|
||||
xfree_null (con->target);
|
||||
xfree (con->target);
|
||||
con->target = url_file_name (u, NULL);
|
||||
locf = con->target;
|
||||
}
|
||||
@ -2473,10 +2473,8 @@ ftp_loop (struct url *u, char **local_file, int *dt, struct url *proxy,
|
||||
/* If a connection was left, quench it. */
|
||||
if (con.csock != -1)
|
||||
fd_close (con.csock);
|
||||
xfree_null (con.id);
|
||||
con.id = NULL;
|
||||
xfree_null (con.target);
|
||||
con.target = NULL;
|
||||
xfree (con.id);
|
||||
xfree (con.target);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -2490,7 +2488,7 @@ delelement (struct fileinfo *f, struct fileinfo **start)
|
||||
struct fileinfo *next = f->next;
|
||||
|
||||
xfree (f->name);
|
||||
xfree_null (f->linkto);
|
||||
xfree (f->linkto);
|
||||
xfree (f);
|
||||
|
||||
if (next)
|
||||
|
@ -46,10 +46,11 @@ as that of the covered work. */
|
||||
# include "utils.h"
|
||||
#else
|
||||
/* Make do without them. */
|
||||
# define xnew(x) xmalloc (sizeof (x))
|
||||
# define xnew_array(type, x) xmalloc (sizeof (type) * (x))
|
||||
# define xmalloc malloc
|
||||
# define xfree free
|
||||
# define xnew(type) (xmalloc (sizeof (type)))
|
||||
# define xnew0(type) (xcalloc (1, sizeof (type)))
|
||||
# define xnew_array(type, len) (xmalloc ((len) * sizeof (type)))
|
||||
# define xfree(p) do { free ((void *) (p)); p = NULL; } while (0)
|
||||
|
||||
# ifndef countof
|
||||
# define countof(x) (sizeof (x) / sizeof ((x)[0]))
|
||||
# endif
|
||||
|
@ -747,8 +747,7 @@ lookup_host (const char *host, int flags)
|
||||
logprintf (LOG_VERBOSE, _("Resolving %s... "),
|
||||
quotearg_style (escape_quoting_style, str ? str : host));
|
||||
|
||||
if (str)
|
||||
xfree (str);
|
||||
xfree (str);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
|
@ -488,8 +488,7 @@ tag_handle_base (int tagid _GL_UNUSED, struct taginfo *tag, struct map_context *
|
||||
base_urlpos->ignore_when_downloading = 1;
|
||||
base_urlpos->link_base_p = 1;
|
||||
|
||||
if (ctx->base)
|
||||
xfree (ctx->base);
|
||||
xfree (ctx->base);
|
||||
if (ctx->parent_base)
|
||||
ctx->base = uri_merge (ctx->parent_base, newbase);
|
||||
else
|
||||
@ -630,7 +629,7 @@ tag_handle_meta (int tagid _GL_UNUSED, struct taginfo *tag, struct map_context *
|
||||
if (!mcharset)
|
||||
return;
|
||||
|
||||
xfree_null (meta_charset);
|
||||
xfree (meta_charset);
|
||||
meta_charset = mcharset;
|
||||
}
|
||||
else if (name && 0 == c_strcasecmp (name, "robots"))
|
||||
@ -758,7 +757,7 @@ get_urls_html (const char *file, const char *url, bool *meta_disallow_follow,
|
||||
if (meta_disallow_follow)
|
||||
*meta_disallow_follow = ctx.nofollow;
|
||||
|
||||
xfree_null (ctx.base);
|
||||
xfree (ctx.base);
|
||||
wget_read_file_free (fm);
|
||||
return ctx.head;
|
||||
}
|
||||
|
119
src/http.c
119
src/http.c
@ -236,7 +236,7 @@ request_set_header (struct request *req, const char *name, const char *value,
|
||||
/* A NULL value is a no-op; if freeing the name is requested,
|
||||
free it now to avoid leaks. */
|
||||
if (release_policy == rel_name || release_policy == rel_both)
|
||||
xfree ((void *)name);
|
||||
xfree (name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -387,10 +387,10 @@ static void
|
||||
request_free (struct request *req)
|
||||
{
|
||||
int i;
|
||||
xfree_null (req->arg);
|
||||
xfree (req->arg);
|
||||
for (i = 0; i < req->hcount; i++)
|
||||
release_header (&req->headers[i]);
|
||||
xfree_null (req->headers);
|
||||
xfree (req->headers);
|
||||
xfree (req);
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ resp_status (const struct response *resp, char **message)
|
||||
static void
|
||||
resp_free (struct response *resp)
|
||||
{
|
||||
xfree_null (resp->headers);
|
||||
xfree (resp->headers);
|
||||
xfree (resp);
|
||||
}
|
||||
|
||||
@ -948,7 +948,7 @@ skip_short_body (int fd, wgint contlen, bool chunked)
|
||||
if (remaining_chunk_size == 0)
|
||||
{
|
||||
line = fd_read_line (fd);
|
||||
xfree_null (line);
|
||||
xfree (line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1475,18 +1475,13 @@ struct http_stat
|
||||
static void
|
||||
free_hstat (struct http_stat *hs)
|
||||
{
|
||||
xfree_null (hs->newloc);
|
||||
xfree_null (hs->remote_time);
|
||||
xfree_null (hs->error);
|
||||
xfree_null (hs->rderrmsg);
|
||||
xfree_null (hs->local_file);
|
||||
xfree_null (hs->orig_file_name);
|
||||
xfree_null (hs->message);
|
||||
|
||||
/* Guard against being called twice. */
|
||||
hs->newloc = NULL;
|
||||
hs->remote_time = NULL;
|
||||
hs->error = NULL;
|
||||
xfree (hs->newloc);
|
||||
xfree (hs->remote_time);
|
||||
xfree (hs->error);
|
||||
xfree (hs->rderrmsg);
|
||||
xfree (hs->local_file);
|
||||
xfree (hs->orig_file_name);
|
||||
xfree (hs->message);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1756,7 +1751,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
hs->res = -1;
|
||||
hs->rderrmsg = NULL;
|
||||
hs->newloc = NULL;
|
||||
xfree(hs->remote_time); hs->remote_time = NULL;
|
||||
xfree(hs->remote_time);
|
||||
hs->error = NULL;
|
||||
hs->message = NULL;
|
||||
|
||||
@ -2078,7 +2073,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
request_free (req);
|
||||
return HERR;
|
||||
}
|
||||
xfree_null(hs->message);
|
||||
xfree(hs->message);
|
||||
hs->message = xstrdup (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
@ -2087,11 +2082,11 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
failed_tunnel:
|
||||
logprintf (LOG_NOTQUIET, _("Proxy tunneling failed: %s"),
|
||||
message ? quotearg_style (escape_quoting_style, message) : "?");
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
request_free (req);
|
||||
return CONSSLERR;
|
||||
}
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
|
||||
/* SOCK is now *really* connected to u->host, so update CONN
|
||||
to reflect this. That way register_persistent will
|
||||
@ -2260,7 +2255,7 @@ read_header:
|
||||
goto read_header;
|
||||
}
|
||||
|
||||
xfree_null(hs->message);
|
||||
xfree(hs->message);
|
||||
hs->message = xstrdup (message);
|
||||
if (!opt.server_response)
|
||||
logprintf (LOG_VERBOSE, "%2d %s\n", statcode,
|
||||
@ -2350,13 +2345,13 @@ read_header:
|
||||
u->url, warc_timestamp_str,
|
||||
warc_request_uuid, warc_ip, type,
|
||||
statcode, head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
|
||||
if (_err != RETRFINISHED || hs->res < 0)
|
||||
{
|
||||
CLOSE_INVALIDATE (sock);
|
||||
request_free (req);
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
return _err;
|
||||
@ -2477,12 +2472,11 @@ read_header:
|
||||
}
|
||||
|
||||
xfree (pth);
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
xfree (auth_stat);
|
||||
xfree (hs->message);
|
||||
hs->message = NULL;
|
||||
goto retry_with_auth;
|
||||
}
|
||||
else
|
||||
@ -2497,7 +2491,7 @@ read_header:
|
||||
}
|
||||
}
|
||||
request_free (req);
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
if (auth_err == RETROK)
|
||||
@ -2521,8 +2515,7 @@ read_header:
|
||||
CLOSE_FINISH (sock);
|
||||
request_free (req);
|
||||
xfree (hs->message);
|
||||
hs->message = NULL;
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
|
||||
@ -2553,7 +2546,7 @@ read_header:
|
||||
hs->local_file = url_file_name (u, local_file);
|
||||
}
|
||||
|
||||
xfree_null (local_file);
|
||||
xfree (local_file);
|
||||
}
|
||||
|
||||
/* TODO: perform this check only once. */
|
||||
@ -2568,7 +2561,7 @@ read_header:
|
||||
request_free (req);
|
||||
resp_free (resp);
|
||||
xfree (head);
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
return RETRUNNEEDED;
|
||||
}
|
||||
else if (!ALLOW_CLOBBER)
|
||||
@ -2651,7 +2644,7 @@ read_header:
|
||||
hs->error = xstrdup (_("(no description)"));
|
||||
else
|
||||
hs->error = xstrdup (message);
|
||||
xfree_null (message);
|
||||
xfree (message);
|
||||
|
||||
type = resp_header_strdup (resp, "Content-Type");
|
||||
if (type)
|
||||
@ -2672,7 +2665,7 @@ read_header:
|
||||
tmp = parse_charset (tmp2);
|
||||
if (tmp)
|
||||
set_content_encoding (iri, tmp);
|
||||
xfree_null(tmp);
|
||||
xfree(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2705,7 +2698,7 @@ read_header:
|
||||
hs->restval = 0;
|
||||
|
||||
CLOSE_FINISH (sock);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
xfree (head);
|
||||
|
||||
return RETRFINISHED;
|
||||
@ -2746,7 +2739,7 @@ read_header:
|
||||
if (_err != RETRFINISHED || hs->res < 0)
|
||||
{
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
xfree (head);
|
||||
return _err;
|
||||
}
|
||||
@ -2763,7 +2756,7 @@ read_header:
|
||||
CLOSE_INVALIDATE (sock);
|
||||
}
|
||||
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
xfree (head);
|
||||
/* From RFC2616: The status codes 303 and 307 have
|
||||
been added for servers that wish to make unambiguously
|
||||
@ -2846,7 +2839,7 @@ read_header:
|
||||
hs->res = 0;
|
||||
/* Mark as successfully retrieved. */
|
||||
*dt |= RETROKF;
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
if (statcode == HTTP_STATUS_RANGE_NOT_SATISFIABLE)
|
||||
CLOSE_FINISH (sock);
|
||||
else
|
||||
@ -2860,7 +2853,7 @@ read_header:
|
||||
{
|
||||
/* The Range request was somehow misunderstood by the server.
|
||||
Bail out. */
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree (head);
|
||||
return RANGEERR;
|
||||
@ -2927,7 +2920,7 @@ read_header:
|
||||
{
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
return _err;
|
||||
}
|
||||
else
|
||||
@ -2952,7 +2945,7 @@ read_header:
|
||||
}
|
||||
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
return RETRFINISHED;
|
||||
}
|
||||
|
||||
@ -2993,7 +2986,7 @@ read_header:
|
||||
strerror (errno));
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
return UNLINKERR;
|
||||
}
|
||||
}
|
||||
@ -3021,7 +3014,7 @@ read_header:
|
||||
hs->local_file);
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
return FOPEN_EXCL_ERR;
|
||||
}
|
||||
}
|
||||
@ -3030,7 +3023,7 @@ read_header:
|
||||
logprintf (LOG_NOTQUIET, "%s: %s\n", hs->local_file, strerror (errno));
|
||||
CLOSE_INVALIDATE (sock);
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
return FOPENERR;
|
||||
}
|
||||
}
|
||||
@ -3050,7 +3043,7 @@ read_header:
|
||||
|
||||
/* Now we no longer need to store the response header. */
|
||||
xfree (head);
|
||||
xfree_null (type);
|
||||
xfree (type);
|
||||
|
||||
if (hs->res >= 0)
|
||||
CLOSE_FINISH (sock);
|
||||
@ -3370,7 +3363,7 @@ Remote file does not exist -- broken link!!!\n"));
|
||||
}
|
||||
logputs (LOG_VERBOSE, "\n");
|
||||
ret = WRONGCODE;
|
||||
xfree_null (hurl);
|
||||
xfree (hurl);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -3494,10 +3487,8 @@ Remote file exists.\n\n"));
|
||||
got_name = true;
|
||||
*dt &= ~HEAD_ONLY;
|
||||
count = 0; /* the retrieve count for HEAD is reset */
|
||||
xfree_null (hstat.message);
|
||||
xfree_null (hstat.error);
|
||||
hstat.message = NULL;
|
||||
hstat.error = NULL;
|
||||
xfree (hstat.message);
|
||||
xfree (hstat.error);
|
||||
continue;
|
||||
} /* send_head_first */
|
||||
} /* !got_head */
|
||||
@ -3646,7 +3637,7 @@ Remote file exists.\n\n"));
|
||||
exit:
|
||||
if (ret == RETROK && local_file)
|
||||
{
|
||||
xfree_null (*local_file);
|
||||
xfree (*local_file);
|
||||
*local_file = xstrdup (hstat.local_file);
|
||||
}
|
||||
free_hstat (&hstat);
|
||||
@ -3866,23 +3857,21 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
if (qop != NULL && strcmp(qop,"auth"))
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Unsupported quality of protection '%s'.\n"), qop);
|
||||
xfree_null (qop); /* force freeing mem and return */
|
||||
qop = NULL;
|
||||
xfree (qop); /* force freeing mem and return */
|
||||
}
|
||||
else if (algorithm != NULL && strcmp (algorithm,"MD5") && strcmp (algorithm,"MD5-sess"))
|
||||
{
|
||||
logprintf (LOG_NOTQUIET, _("Unsupported algorithm '%s'.\n"), algorithm);
|
||||
xfree_null (qop); /* force freeing mem and return */
|
||||
qop = NULL;
|
||||
xfree (qop); /* force freeing mem and return */
|
||||
}
|
||||
|
||||
if (!realm || !nonce || !user || !passwd || !path || !method || !qop)
|
||||
{
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
xfree_null (qop);
|
||||
xfree_null (algorithm);
|
||||
xfree (realm);
|
||||
xfree (opaque);
|
||||
xfree (nonce);
|
||||
xfree (qop);
|
||||
xfree (algorithm);
|
||||
if (!qop)
|
||||
*auth_err = UNKNOWNATTR;
|
||||
else
|
||||
@ -4009,11 +3998,11 @@ digest_authentication_encode (const char *au, const char *user,
|
||||
}
|
||||
}
|
||||
|
||||
xfree_null (realm);
|
||||
xfree_null (opaque);
|
||||
xfree_null (nonce);
|
||||
xfree_null (qop);
|
||||
xfree_null (algorithm);
|
||||
xfree (realm);
|
||||
xfree (opaque);
|
||||
xfree (nonce);
|
||||
xfree (qop);
|
||||
xfree (algorithm);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -4108,7 +4097,7 @@ save_cookies (void)
|
||||
void
|
||||
http_cleanup (void)
|
||||
{
|
||||
xfree_null (pconn.host);
|
||||
xfree (pconn.host);
|
||||
if (wget_cookie_jar)
|
||||
cookie_jar_delete (wget_cookie_jar);
|
||||
}
|
||||
|
86
src/init.c
86
src/init.c
@ -527,7 +527,7 @@ wgetrc_user_file_name (void)
|
||||
home = home_dir ();
|
||||
if (home)
|
||||
file = aprintf ("%s/.wgetrc", home);
|
||||
xfree_null (home);
|
||||
xfree (home);
|
||||
#endif /* def __VMS [else] */
|
||||
|
||||
if (!file)
|
||||
@ -562,8 +562,7 @@ wgetrc_file_name (void)
|
||||
if (!file)
|
||||
{
|
||||
char *home = home_dir ();
|
||||
xfree_null (file);
|
||||
file = NULL;
|
||||
xfree (file);
|
||||
home = ws_mypath ();
|
||||
if (home)
|
||||
{
|
||||
@ -571,7 +570,6 @@ wgetrc_file_name (void)
|
||||
if (!file_exists_p (file))
|
||||
{
|
||||
xfree (file);
|
||||
file = NULL;
|
||||
}
|
||||
xfree (home);
|
||||
}
|
||||
@ -645,8 +643,8 @@ run_wgetrc (const char *file)
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
xfree_null (com);
|
||||
xfree_null (val);
|
||||
xfree (com);
|
||||
xfree (val);
|
||||
++ln;
|
||||
}
|
||||
xfree (line);
|
||||
@ -982,7 +980,7 @@ cmd_string (const char *com _GL_UNUSED, const char *val, void *place)
|
||||
{
|
||||
char **pstring = (char **)place;
|
||||
|
||||
xfree_null (*pstring);
|
||||
xfree (*pstring);
|
||||
*pstring = xstrdup (val);
|
||||
return true;
|
||||
}
|
||||
@ -993,7 +991,7 @@ cmd_string_uppercase (const char *com _GL_UNUSED, const char *val, void *place)
|
||||
{
|
||||
char *q, **pstring;
|
||||
pstring = (char **)place;
|
||||
xfree_null (*pstring);
|
||||
xfree (*pstring);
|
||||
|
||||
*pstring = xmalloc (strlen (val) + 1);
|
||||
|
||||
@ -1013,7 +1011,7 @@ cmd_file (const char *com _GL_UNUSED, const char *val, void *place)
|
||||
{
|
||||
char **pstring = (char **)place;
|
||||
|
||||
xfree_null (*pstring);
|
||||
xfree (*pstring);
|
||||
|
||||
/* #### If VAL is empty, perhaps should set *PLACE to NULL. */
|
||||
|
||||
@ -1418,7 +1416,7 @@ cmd_spec_progress (const char *com, const char *val, void *place_ignored _GL_UNU
|
||||
exec_name, com, quote (val));
|
||||
return false;
|
||||
}
|
||||
xfree_null (opt.progress_type);
|
||||
xfree (opt.progress_type);
|
||||
|
||||
/* Don't call set_progress_implementation here. It will be called
|
||||
in main when it becomes clear what the log output is. */
|
||||
@ -1569,7 +1567,7 @@ cmd_spec_useragent (const char *com, const char *val, void *place_ignored _GL_UN
|
||||
exec_name, com, quote (val));
|
||||
return false;
|
||||
}
|
||||
xfree_null (opt.useragent);
|
||||
xfree (opt.useragent);
|
||||
opt.useragent = xstrdup (val);
|
||||
return true;
|
||||
}
|
||||
@ -1769,11 +1767,11 @@ cleanup (void)
|
||||
log_cleanup ();
|
||||
netrc_cleanup ();
|
||||
|
||||
xfree_null (opt.choose_config);
|
||||
xfree_null (opt.lfilename);
|
||||
xfree_null (opt.dir_prefix);
|
||||
xfree_null (opt.input_filename);
|
||||
xfree_null (opt.output_document);
|
||||
xfree (opt.choose_config);
|
||||
xfree (opt.lfilename);
|
||||
xfree (opt.dir_prefix);
|
||||
xfree (opt.input_filename);
|
||||
xfree (opt.output_document);
|
||||
free_vec (opt.accepts);
|
||||
free_vec (opt.rejects);
|
||||
free_vec ((char **)opt.excludes);
|
||||
@ -1781,39 +1779,39 @@ cleanup (void)
|
||||
free_vec (opt.domains);
|
||||
free_vec (opt.follow_tags);
|
||||
free_vec (opt.ignore_tags);
|
||||
xfree_null (opt.progress_type);
|
||||
xfree_null (opt.ftp_user);
|
||||
xfree_null (opt.ftp_passwd);
|
||||
xfree_null (opt.ftp_proxy);
|
||||
xfree_null (opt.https_proxy);
|
||||
xfree_null (opt.http_proxy);
|
||||
xfree (opt.progress_type);
|
||||
xfree (opt.ftp_user);
|
||||
xfree (opt.ftp_passwd);
|
||||
xfree (opt.ftp_proxy);
|
||||
xfree (opt.https_proxy);
|
||||
xfree (opt.http_proxy);
|
||||
free_vec (opt.no_proxy);
|
||||
xfree_null (opt.useragent);
|
||||
xfree_null (opt.referer);
|
||||
xfree_null (opt.http_user);
|
||||
xfree_null (opt.http_passwd);
|
||||
xfree (opt.useragent);
|
||||
xfree (opt.referer);
|
||||
xfree (opt.http_user);
|
||||
xfree (opt.http_passwd);
|
||||
free_vec (opt.user_headers);
|
||||
free_vec (opt.warc_user_headers);
|
||||
# ifdef HAVE_SSL
|
||||
xfree_null (opt.cert_file);
|
||||
xfree_null (opt.private_key);
|
||||
xfree_null (opt.ca_directory);
|
||||
xfree_null (opt.ca_cert);
|
||||
xfree_null (opt.crl_file);
|
||||
xfree_null (opt.random_file);
|
||||
xfree_null (opt.egd_file);
|
||||
xfree (opt.cert_file);
|
||||
xfree (opt.private_key);
|
||||
xfree (opt.ca_directory);
|
||||
xfree (opt.ca_cert);
|
||||
xfree (opt.crl_file);
|
||||
xfree (opt.random_file);
|
||||
xfree (opt.egd_file);
|
||||
# endif
|
||||
xfree_null (opt.bind_address);
|
||||
xfree_null (opt.cookies_input);
|
||||
xfree_null (opt.cookies_output);
|
||||
xfree_null (opt.user);
|
||||
xfree_null (opt.passwd);
|
||||
xfree_null (opt.base_href);
|
||||
xfree_null (opt.method);
|
||||
xfree_null (opt.post_file_name);
|
||||
xfree_null (opt.post_data);
|
||||
xfree_null (opt.body_data);
|
||||
xfree_null (opt.body_file);
|
||||
xfree (opt.bind_address);
|
||||
xfree (opt.cookies_input);
|
||||
xfree (opt.cookies_output);
|
||||
xfree (opt.user);
|
||||
xfree (opt.passwd);
|
||||
xfree (opt.base_href);
|
||||
xfree (opt.method);
|
||||
xfree (opt.post_file_name);
|
||||
xfree (opt.post_data);
|
||||
xfree (opt.body_data);
|
||||
xfree (opt.body_file);
|
||||
|
||||
#endif /* DEBUG_MALLOC */
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ remote_to_utf8 (struct iri *iri, const char *str, const char **new)
|
||||
/* Test if something was converted */
|
||||
if (*new && !strcmp (str, *new))
|
||||
{
|
||||
xfree ((char *) *new);
|
||||
xfree (*new);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -329,9 +329,9 @@ struct iri *iri_dup (const struct iri *src)
|
||||
void
|
||||
iri_free (struct iri *i)
|
||||
{
|
||||
xfree_null (i->uri_encoding);
|
||||
xfree_null (i->content_encoding);
|
||||
xfree_null (i->orig_url);
|
||||
xfree (i->uri_encoding);
|
||||
xfree (i->content_encoding);
|
||||
xfree (i->orig_url);
|
||||
xfree (i);
|
||||
}
|
||||
|
||||
|
11
src/log.c
11
src/log.c
@ -156,11 +156,7 @@ static void
|
||||
free_log_line (int num)
|
||||
{
|
||||
struct log_ln *ln = log_lines + num;
|
||||
if (ln->malloced_line)
|
||||
{
|
||||
xfree (ln->malloced_line);
|
||||
ln->malloced_line = NULL;
|
||||
}
|
||||
xfree (ln->malloced_line);
|
||||
ln->content = NULL;
|
||||
}
|
||||
|
||||
@ -451,8 +447,7 @@ log_vprintf_internal (struct logvprintf_state *state, const char *fmt,
|
||||
FPUTS (write_ptr, fp);
|
||||
if (warcfp != NULL)
|
||||
FPUTS (write_ptr, warcfp);
|
||||
if (state->bigmsg)
|
||||
xfree (state->bigmsg);
|
||||
xfree (state->bigmsg);
|
||||
|
||||
flush:
|
||||
if (flush_log_p)
|
||||
@ -847,7 +842,7 @@ log_cleanup (void)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < countof (ring); i++)
|
||||
xfree_null (ring[i].buffer);
|
||||
xfree (ring[i].buffer);
|
||||
}
|
||||
|
||||
/* When SIGHUP or SIGUSR1 are received, the output is redirected
|
||||
|
@ -889,7 +889,7 @@ format_and_print_line (const char *prefix, const char *line,
|
||||
}
|
||||
if (printf ("%s ", token) < 0)
|
||||
{
|
||||
xfree_null (line_dup);
|
||||
xfree (line_dup);
|
||||
return -1;
|
||||
}
|
||||
remaining_chars -= strlen (token) + 1; /* account for " " */
|
||||
@ -1481,13 +1481,11 @@ for details.\n\n"));
|
||||
{
|
||||
setoptval ("bodydata", opt.post_data, "body-data");
|
||||
xfree(opt.post_data);
|
||||
opt.post_data = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
setoptval ("bodyfile", opt.post_file_name, "body-file");
|
||||
xfree(opt.post_file_name);
|
||||
opt.post_file_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1698,8 +1696,8 @@ outputting to a regular file.\n"));
|
||||
if (unlink (filename))
|
||||
logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno));
|
||||
}
|
||||
xfree_null (redirected_URL);
|
||||
xfree_null (filename);
|
||||
xfree (redirected_URL);
|
||||
xfree (filename);
|
||||
url_free (url_parsed);
|
||||
}
|
||||
iri_free (iri);
|
||||
|
@ -367,8 +367,8 @@ static int old_percentage = -1;
|
||||
void
|
||||
ws_changetitle (const char *url)
|
||||
{
|
||||
xfree_null (title_buf);
|
||||
xfree_null (curr_url);
|
||||
xfree (title_buf);
|
||||
xfree (curr_url);
|
||||
title_buf = xmalloc (strlen (url) + 20);
|
||||
curr_url = xstrdup (url);
|
||||
old_percentage = -1;
|
||||
|
14
src/netrc.c
14
src/netrc.c
@ -163,7 +163,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
|
||||
|
||||
/* Normally, these functions would be defined by your package. */
|
||||
# define xmalloc malloc
|
||||
# define xfree free
|
||||
# define xfree(p) do { free ((void *) (p)); p = NULL; } while (0)
|
||||
# define xstrdup strdup
|
||||
|
||||
# define xrealloc realloc
|
||||
@ -183,9 +183,9 @@ maybe_add_to_list (acc_t **newentry, acc_t **list)
|
||||
if (a && ! a->acc)
|
||||
{
|
||||
/* Free any allocated space. */
|
||||
xfree_null (a->host);
|
||||
xfree_null (a->acc);
|
||||
xfree_null (a->passwd);
|
||||
xfree (a->host);
|
||||
xfree (a->acc);
|
||||
xfree (a->passwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -424,9 +424,9 @@ free_netrc(acc_t *l)
|
||||
while (l)
|
||||
{
|
||||
t = l->next;
|
||||
xfree_null (l->acc);
|
||||
xfree_null (l->passwd);
|
||||
xfree_null (l->host);
|
||||
xfree (l->acc);
|
||||
xfree (l->passwd);
|
||||
xfree (l->host);
|
||||
xfree (l);
|
||||
l = t;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ openssl_errstr (int fd _GL_UNUSED, void *arg)
|
||||
return NULL;
|
||||
|
||||
/* Get rid of previous contents of ctx->last_error, if any. */
|
||||
xfree_null (ctx->last_error);
|
||||
xfree (ctx->last_error);
|
||||
|
||||
/* Iterate over OpenSSL's error stack and accumulate errors in the
|
||||
last_error buffer, separated by "; ". This is better than using
|
||||
@ -460,7 +460,7 @@ openssl_close (int fd, void *arg)
|
||||
|
||||
SSL_shutdown (conn);
|
||||
SSL_free (conn);
|
||||
xfree_null (ctx->last_error);
|
||||
xfree (ctx->last_error);
|
||||
xfree (ctx);
|
||||
|
||||
close (fd);
|
||||
|
@ -461,8 +461,8 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi)
|
||||
}
|
||||
|
||||
xfree (url);
|
||||
xfree_null (referer);
|
||||
xfree_null (file);
|
||||
xfree (referer);
|
||||
xfree (file);
|
||||
iri_free (i);
|
||||
}
|
||||
|
||||
@ -478,7 +478,7 @@ retrieve_tree (struct url *start_url_parsed, struct iri *pi)
|
||||
{
|
||||
iri_free (d6);
|
||||
xfree (d1);
|
||||
xfree_null (d2);
|
||||
xfree (d2);
|
||||
}
|
||||
}
|
||||
url_queue_delete (queue);
|
||||
|
@ -404,7 +404,7 @@ free_specs (struct robot_specs *specs)
|
||||
int i;
|
||||
for (i = 0; i < specs->count; i++)
|
||||
xfree (specs->paths[i].path);
|
||||
xfree_null (specs->paths);
|
||||
xfree (specs->paths);
|
||||
xfree (specs);
|
||||
}
|
||||
|
||||
@ -579,7 +579,6 @@ res_retrieve_file (const char *url, char **file, struct iri *iri)
|
||||
allocated the file name, deallocate is here so that the
|
||||
caller doesn't have to worry about it. */
|
||||
xfree (*file);
|
||||
*file = NULL;
|
||||
}
|
||||
return err == RETROK;
|
||||
}
|
||||
|
21
src/retr.c
21
src/retr.c
@ -550,7 +550,7 @@ fd_read_hunk (int fd, hunk_terminator_t terminator, long sizehint, long maxsize)
|
||||
rdlen = fd_read (fd, hunk + tail, remain, 0);
|
||||
if (rdlen < 0)
|
||||
{
|
||||
xfree_null (hunk);
|
||||
xfree (hunk);
|
||||
return NULL;
|
||||
}
|
||||
tail += rdlen;
|
||||
@ -839,8 +839,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
|
||||
assert (mynewloc != NULL);
|
||||
|
||||
if (local_file)
|
||||
xfree (local_file);
|
||||
xfree (local_file);
|
||||
|
||||
/* The HTTP specs only allow absolute URLs to appear in
|
||||
redirects, but a ton of boneheaded webservers and CGIs out
|
||||
@ -854,8 +853,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
the content encoding. */
|
||||
iri->utf8_encode = opt.enable_iri;
|
||||
set_content_encoding (iri, NULL);
|
||||
xfree_null (iri->orig_url);
|
||||
iri->orig_url = NULL;
|
||||
xfree (iri->orig_url);
|
||||
|
||||
/* Now, see if this new location makes sense. */
|
||||
newloc_parsed = url_parse (mynewloc, &up_error_code, iri, true);
|
||||
@ -964,7 +962,7 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file,
|
||||
if (file)
|
||||
*file = local_file ? local_file : NULL;
|
||||
else
|
||||
xfree_null (local_file);
|
||||
xfree (local_file);
|
||||
|
||||
if (orig_parsed != u)
|
||||
{
|
||||
@ -1048,8 +1046,7 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
|
||||
/* Reset UTF-8 encode status */
|
||||
iri->utf8_encode = opt.enable_iri;
|
||||
xfree_null (iri->orig_url);
|
||||
iri->orig_url = NULL;
|
||||
xfree (iri->orig_url);
|
||||
|
||||
input_file = url_file;
|
||||
}
|
||||
@ -1059,7 +1056,7 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
url_list = (html ? get_urls_html (input_file, NULL, NULL, iri)
|
||||
: get_urls_file (input_file));
|
||||
|
||||
xfree_null (url_file);
|
||||
xfree (url_file);
|
||||
|
||||
for (cur_url = url_list; cur_url; cur_url = cur_url->next, ++*count)
|
||||
{
|
||||
@ -1114,8 +1111,8 @@ Removing file due to --delete-after in retrieve_from_file():\n"));
|
||||
dt &= ~RETROKF;
|
||||
}
|
||||
|
||||
xfree_null (new_file);
|
||||
xfree_null (filename);
|
||||
xfree (new_file);
|
||||
xfree (filename);
|
||||
iri_free (tmpiri);
|
||||
}
|
||||
|
||||
@ -1191,7 +1188,7 @@ free_urlpos (struct urlpos *l)
|
||||
struct urlpos *next = l->next;
|
||||
if (l->url)
|
||||
url_free (l->url);
|
||||
xfree_null (l->local_name);
|
||||
xfree (l->local_name);
|
||||
xfree (l);
|
||||
l = next;
|
||||
}
|
||||
|
16
src/url.c
16
src/url.c
@ -706,7 +706,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
|
||||
new_url = NULL;
|
||||
else
|
||||
{
|
||||
xfree_null (iri->orig_url);
|
||||
xfree (iri->orig_url);
|
||||
iri->orig_url = xstrdup (url);
|
||||
url_encoded = reencode_escapes (new_url);
|
||||
if (url_encoded != new_url)
|
||||
@ -917,7 +917,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
|
||||
u->url = url_string (u, URL_AUTH_SHOW);
|
||||
|
||||
if (url_encoded != url)
|
||||
xfree ((char *) url_encoded);
|
||||
xfree (url_encoded);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -932,7 +932,7 @@ url_parse (const char *url, int *error, struct iri *iri, bool percent_encode)
|
||||
error:
|
||||
/* Cleanup in case of error: */
|
||||
if (url_encoded && url_encoded != url)
|
||||
xfree ((char *) url_encoded);
|
||||
xfree (url_encoded);
|
||||
|
||||
/* Transmit the error code to the caller, if the caller wants to
|
||||
know. */
|
||||
@ -1177,11 +1177,11 @@ url_free (struct url *url)
|
||||
xfree (url->path);
|
||||
xfree (url->url);
|
||||
|
||||
xfree_null (url->params);
|
||||
xfree_null (url->query);
|
||||
xfree_null (url->fragment);
|
||||
xfree_null (url->user);
|
||||
xfree_null (url->passwd);
|
||||
xfree (url->params);
|
||||
xfree (url->query);
|
||||
xfree (url->fragment);
|
||||
xfree (url->user);
|
||||
xfree (url->passwd);
|
||||
|
||||
xfree (url->dir);
|
||||
xfree (url->file);
|
||||
|
@ -47,12 +47,7 @@ as that of the covered work. */
|
||||
|
||||
#define alloca_array(type, size) ((type *) alloca ((size) * sizeof (type)))
|
||||
|
||||
#define xfree free
|
||||
/* Free P if it is non-NULL. C requires free() to behaves this way by
|
||||
default, but Wget's code is historically careful not to pass NULL
|
||||
to free. This allows us to assert p!=NULL in xfree to check
|
||||
additional errors. (But we currently don't do that!) */
|
||||
#define xfree_null(p) if (!(p)) ; else xfree (p)
|
||||
#define xfree(p) do { free ((void *) (p)); p = NULL; } while (0)
|
||||
|
||||
struct hash_table;
|
||||
|
||||
|
@ -939,9 +939,9 @@ warc_process_cdx_line (char *lineptr, int field_num_original_url,
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree_null(checksum);
|
||||
xfree_null(original_url);
|
||||
xfree_null(record_id);
|
||||
xfree(checksum);
|
||||
xfree(original_url);
|
||||
xfree(record_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user