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

@ -7,6 +7,7 @@
(as OSX has done) and mark the numbered macros as obsolete.
* Source/NSMessagePort.m:
* Source/NSSocketPort.m: Log if we fail to tuirn on keepalive
* Source/NSURL.m: fix possible nul pointer dereference
2018-02-05 Richard Frith-Macdonald <rfm@gnu.org>

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);