summaryrefslogtreecommitdiff
path: root/lib/libX11/src/GetFPath.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libX11/src/GetFPath.c')
-rw-r--r--lib/libX11/src/GetFPath.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libX11/src/GetFPath.c b/lib/libX11/src/GetFPath.c
index 8c3f49c95..87d257615 100644
--- a/lib/libX11/src/GetFPath.c
+++ b/lib/libX11/src/GetFPath.c
@@ -42,7 +42,7 @@ char **XGetFontPath(
int count = 0;
register unsigned i;
register int length;
- register xReq *req;
+ _X_UNUSED register xReq *req;
LockDisplay(dpy);
GetEmptyReq (GetFontPath, req);
@@ -69,15 +69,20 @@ char **XGetFontPath(
/*
* unpack into null terminated strings.
*/
- chend = ch + (nbytes + 1);
- length = *ch;
+ chend = ch + nbytes;
+ length = *(unsigned char *)ch;
for (i = 0; i < rep.nPaths; i++) {
if (ch + length < chend) {
flist[i] = ch+1; /* skip over length */
ch += length + 1; /* find next length ... */
- length = *ch;
+ length = *(unsigned char *)ch;
*ch = '\0'; /* and replace with null-termination */
count++;
+ } else if (i == 0) {
+ Xfree(flist);
+ Xfree(ch);
+ flist = NULL;
+ break;
} else
flist[i] = NULL;
}