mirror of
https://github.com/mirror/wget.git
synced 2025-03-13 11:20:19 +08:00
* src/convert.c (replace_attr_refresh_hack): Remove use of alloca
This commit is contained in:
parent
43ad3af58d
commit
951bcac6df
@ -666,11 +666,18 @@ replace_attr_refresh_hack (const char *p, int size, FILE *fp,
|
|||||||
const char *new_text, int timeout)
|
const char *new_text, int timeout)
|
||||||
{
|
{
|
||||||
/* "0; URL=..." */
|
/* "0; URL=..." */
|
||||||
char *new_with_timeout = (char *)alloca (numdigit (timeout)
|
char new_with_timeout[1024];
|
||||||
+ 6 /* "; URL=" */
|
|
||||||
+ strlen (new_text)
|
if (((unsigned) snprintf (
|
||||||
+ 1);
|
new_with_timeout, sizeof (new_with_timeout),
|
||||||
sprintf (new_with_timeout, "%d; URL=%s", timeout, new_text);
|
"%d; URL=%s", timeout, new_text)) >= sizeof (new_with_timeout))
|
||||||
|
{
|
||||||
|
// very unlikely fallback using heap memory
|
||||||
|
char *tmp = aprintf("%d; URL=%s", timeout, new_text);
|
||||||
|
const char *res = replace_attr (p, size, fp, tmp);
|
||||||
|
xfree (tmp);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
return replace_attr (p, size, fp, new_with_timeout);
|
return replace_attr (p, size, fp, new_with_timeout);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user