1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Fix issues reported by static code analysis tool 'parfait'

Closes: #41235
Reported-by: Jiri Kukacka
This commit is contained in:
Tim Rühsen 2014-12-01 17:02:33 +01:00 committed by Tim Ruehsen
parent 4850e9c873
commit e4583ab364
5 changed files with 36 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2014-12-01 Tim Ruehsen <tim.ruehsen@gmx.de>
* connect.c, iri.c, url.c, warc.c: Fix issues reported
by static code analysis tool 'parfait'.
Closes: #41235
Reported-by: Jiri Kukacka
2014-11-29 Tim Ruehsen <tim.ruehsen@gmx.de> 2014-11-29 Tim Ruehsen <tim.ruehsen@gmx.de>
* utils.h: xfree() sets argument to NULL after freeing, * utils.h: xfree() sets argument to NULL after freeing,

View File

@ -844,7 +844,7 @@ void *
fd_transport_context (int fd) fd_transport_context (int fd)
{ {
struct transport_info *info = hash_table_get (transport_map, (void *)(intptr_t) fd); struct transport_info *info = hash_table_get (transport_map, (void *)(intptr_t) fd);
return info->ctx; return info ? info->ctx : NULL;
} }
/* When fd_read/fd_write are called multiple times in a loop, they should /* When fd_read/fd_write are called multiple times in a loop, they should

View File

@ -329,10 +329,13 @@ struct iri *iri_dup (const struct iri *src)
void void
iri_free (struct iri *i) iri_free (struct iri *i)
{ {
xfree (i->uri_encoding); if (i)
xfree (i->content_encoding); {
xfree (i->orig_url); xfree (i->uri_encoding);
xfree (i); xfree (i->content_encoding);
xfree (i->orig_url);
xfree (i);
}
} }
/* Set uri_encoding of struct iri i. If a remote encoding was specified, use /* Set uri_encoding of struct iri i. If a remote encoding was specified, use

View File

@ -575,8 +575,8 @@ rewrite_shorthand_url (const char *url)
goto http; goto http;
/* Turn "foo.bar.com:path" to "ftp://foo.bar.com/path". */ /* Turn "foo.bar.com:path" to "ftp://foo.bar.com/path". */
ret = aprintf ("ftp://%s", url); if ((ret = aprintf ("ftp://%s", url)) != NULL)
ret[6 + (p - url)] = '/'; ret[6 + (p - url)] = '/';
} }
else else
{ {
@ -1173,20 +1173,23 @@ url_set_file (struct url *url, const char *newfile)
void void
url_free (struct url *url) url_free (struct url *url)
{ {
xfree (url->host); if (url)
xfree (url->path); {
xfree (url->url); xfree (url->host);
xfree (url->path);
xfree (url->url);
xfree (url->params); xfree (url->params);
xfree (url->query); xfree (url->query);
xfree (url->fragment); xfree (url->fragment);
xfree (url->user); xfree (url->user);
xfree (url->passwd); xfree (url->passwd);
xfree (url->dir); xfree (url->dir);
xfree (url->file); xfree (url->file);
xfree (url); xfree (url);
}
} }
/* Create all the necessary directories for PATH (a file). Calls /* Create all the necessary directories for PATH (a file). Calls

View File

@ -1201,7 +1201,10 @@ warc_tempfile (void)
#if !O_TEMPORARY #if !O_TEMPORARY
if (unlink (filename) < 0) if (unlink (filename) < 0)
return NULL; {
close(fd);
return NULL;
}
#endif #endif
return fdopen (fd, "wb+"); return fdopen (fd, "wb+");