fix possible nul pointer deref

This commit is contained in:
Richard Frith-Macdonald 2018-02-06 12:43:55 +00:00
parent 3d98433cc7
commit f7c71c695e
2 changed files with 12 additions and 7 deletions

View file

@ -347,14 +347,18 @@ static char *buildURL(parsedURL *base, parsedURL *rel, BOOL standardize)
else
{
char *start = base->path;
char *end = strrchr(start, '/');
if (end != 0)
{
*tmp++ = '/';
memcpy(tmp, start, end - start);
tmp += (end - start);
}
if (start != 0)
{
char *end = strrchr(start, '/');
if (end != 0)
{
*tmp++ = '/';
memcpy(tmp, start, end - start);
tmp += (end - start);
}
}
*tmp++ = '/';
l = strlen(rpath);
memcpy(tmp, rpath, l);