* 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
---
src/http.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/http.c b/src/http.c
index 4466b31..8fdf49d 100644
--- a/src/http.c
+++ b/src/http.c
@@ -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,7 +4500,10 @@ exit:
if ((ret == RETROK || opt.content_on_error) && local_file)
{
xfree (*local_file);
- *local_file = xstrdup (hstat.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);
--
2.7.3