wget/backport-src-main.c-main-Remove-use-of-alloca.patch

41 lines
1.0 KiB
Diff

From f460e1d04963dce88b9711002c655497a8a22390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
Date: Thu, 13 Feb 2020 15:17:27 +0100
Subject: [PATCH] * src/main.c (main): Remove use of alloca
diff --git a/src/main.c b/src/main.c
index 4d595ef0..3b6e49fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1934,7 +1934,7 @@ for details.\n\n"));
set_progress_implementation (opt.progress_type);
/* Fill in the arguments. */
- url = alloca_array (char *, nurl + 1);
+ url = xmalloc (sizeof (char *) * (nurl + 1));
if (url == NULL)
{
fprintf (stderr, _("Memory allocation problem\n"));
@@ -1946,7 +1946,7 @@ for details.\n\n"));
if (rewritten)
url[i] = rewritten;
else
- url[i] = xstrdup (argv[optind]);
+ url[i] = argv[optind];
}
url[i] = NULL;
@@ -2180,6 +2180,8 @@ only if outputting to a regular file.\n"));
iri_free (iri);
}
+ xfree(url);
+
/* And then from the input file, if any. */
if (opt.input_filename)
{
--
2.33.0