mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Handle correctly some malloc failures.
This commit is contained in:
parent
611a219fb0
commit
bcc2abf116
@ -1,5 +1,7 @@
|
||||
2012-02-23 Giuseppe Scrivano <giuseppe@southpole.se>
|
||||
|
||||
* main.c (main): Fail gracefully if `malloc' fails.
|
||||
|
||||
* gnutls.c (wgnutls_read): Remove unused variables `timer' and `flags'.
|
||||
|
||||
2012-02-17 Steven Schubiger <stsc@member.fsf.org>
|
||||
|
26
src/main.c
26
src/main.c
@ -988,15 +988,20 @@ main (int argc, char **argv)
|
||||
for (i = 1; i < argc; i++)
|
||||
argstring_length += strlen (argv[i]) + 2 + 1;
|
||||
char *p = program_argstring = malloc (argstring_length * sizeof (char));
|
||||
if (p == NULL)
|
||||
{
|
||||
fprintf (stderr, _("Memory allocation problem\n"));
|
||||
exit (2);
|
||||
}
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
*p++ = '"';
|
||||
int arglen = strlen (argv[i]);
|
||||
memcpy (p, argv[i], arglen);
|
||||
p += arglen;
|
||||
*p++ = '"';
|
||||
*p++ = ' ';
|
||||
}
|
||||
{
|
||||
*p++ = '"';
|
||||
int arglen = strlen (argv[i]);
|
||||
memcpy (p, argv[i], arglen);
|
||||
p += arglen;
|
||||
*p++ = '"';
|
||||
*p++ = ' ';
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
/* Load the hard-coded defaults. */
|
||||
@ -1355,6 +1360,11 @@ for details.\n\n"));
|
||||
|
||||
/* Fill in the arguments. */
|
||||
url = alloca_array (char *, nurl + 1);
|
||||
if (url == NULL)
|
||||
{
|
||||
fprintf (stderr, _("Memory allocation problem\n"));
|
||||
exit (2);
|
||||
}
|
||||
for (i = 0; i < nurl; i++, optind++)
|
||||
{
|
||||
char *rewritten = rewrite_shorthand_url (argv[optind]);
|
||||
|
Loading…
Reference in New Issue
Block a user