Bugfix: Set NULL variable due to --content-disposition to Metalink origin

* src/http.c (http_loop): Prevent SIGSEGV when hstat.local_file is
  NULL, opt.content_disposition has a role in leaving the value unset
* src/http.c (gethttp): If hs->local_file is NULL (aka http_loop()'s
  hstat.local_file), set it to the value of hs->metalink->origin
This commit is contained in:
Matthew White 2016-08-30 12:09:38 +02:00
parent c89767d8d1
commit 3021466817

View File

@ -3378,6 +3378,9 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs,
if (metalink)
{
hs->metalink = metalink_from_http (resp, hs, u);
/* Bugfix: hs->local_file is NULL (opt.content_disposition). */
if (!hs->local_file && hs->metalink && hs->metalink->origin)
hs->local_file = xstrdup (hs->metalink->origin);
xfree (hs->message);
retval = RETR_WITH_METALINK;
CLOSE_FINISH (sock);
@ -4497,6 +4500,9 @@ exit:
if ((ret == RETROK || opt.content_on_error) && local_file)
{
xfree (*local_file);
/* Bugfix: Prevent SIGSEGV when hstat.local_file was left NULL
(i.e. due to opt.content_disposition). */
if (hstat.local_file)
*local_file = xstrdup (hstat.local_file);
}
free_hstat (&hstat);