mirror of
https://github.com/mirror/wget.git
synced 2025-03-25 01:00:13 +08:00
* src/url.c (append_uri_pathel): Replace alloca by fixed array / xmalloc
This commit is contained in:
parent
9adde1e441
commit
c2d03b6293
16
src/url.c
16
src/url.c
@ -1462,6 +1462,8 @@ append_uri_pathel (const char *b, const char *e, bool escaped,
|
|||||||
struct growable *dest)
|
struct growable *dest)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
|
char buf[1024];
|
||||||
|
char *unescaped = NULL;
|
||||||
int quoted, outlen;
|
int quoted, outlen;
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
@ -1481,8 +1483,15 @@ append_uri_pathel (const char *b, const char *e, bool escaped,
|
|||||||
/* Copy [b, e) to PATHEL and URL-unescape it. */
|
/* Copy [b, e) to PATHEL and URL-unescape it. */
|
||||||
if (escaped)
|
if (escaped)
|
||||||
{
|
{
|
||||||
char *unescaped;
|
size_t len = e - b;
|
||||||
BOUNDED_TO_ALLOCA (b, e, unescaped);
|
if (len < sizeof (buf))
|
||||||
|
unescaped = buf;
|
||||||
|
else
|
||||||
|
unescaped = xmalloc(len + 1);
|
||||||
|
|
||||||
|
memcpy(unescaped, b, len);
|
||||||
|
unescaped[len] = 0;
|
||||||
|
|
||||||
url_unescape (unescaped);
|
url_unescape (unescaped);
|
||||||
b = unescaped;
|
b = unescaped;
|
||||||
e = unescaped + strlen (unescaped);
|
e = unescaped + strlen (unescaped);
|
||||||
@ -1549,6 +1558,9 @@ append_uri_pathel (const char *b, const char *e, bool escaped,
|
|||||||
|
|
||||||
TAIL_INCR (dest, outlen);
|
TAIL_INCR (dest, outlen);
|
||||||
append_null (dest);
|
append_null (dest);
|
||||||
|
|
||||||
|
if (unescaped && unescaped != buf)
|
||||||
|
free (unescaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
|
Loading…
Reference in New Issue
Block a user