1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | #ifdef HAVE_CONFIG_H1 |
28 | #include <config.h> |
29 | #endif |
30 | #include "Xlibint.h" |
31 | |
32 | #define safestrlen(s)((s) ? strlen(s) : 0) ((s) ? strlen(s) : 0) |
33 | |
34 | int |
35 | XSetFontPath ( |
36 | register Display *dpy, |
37 | char **directories, |
38 | int ndirs) |
39 | { |
40 | register int n = 0; |
41 | register int i; |
42 | register int nbytes; |
43 | char *p; |
44 | register xSetFontPathReq *req; |
45 | int retCode; |
46 | |
47 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
48 | GetReq (SetFontPath, req)req = (xSetFontPathReq *) _XGetRequest(dpy, 51, 8); |
49 | req->nFonts = ndirs; |
50 | for (i = 0; i < ndirs; i++) { |
| 1 | Assuming 'i' is < 'ndirs' |
|
| 2 | Loop condition is true. Entering loop body |
|
| 3 | Assuming 'i' is >= 'ndirs' |
|
| 4 | Loop condition is false. Execution continues on line 53 |
|
51 | n += safestrlen (directories[i])((directories[i]) ? strlen(directories[i]) : 0) + 1; |
52 | } |
53 | nbytes = (n + 3) & ~3; |
54 | req->length += nbytes >> 2; |
55 | if ((p = (char *) Xmalloc ((unsigned) nbytes)malloc((((unsigned) nbytes) == 0 ? 1 : ((unsigned) nbytes))))) { |
| 5 | Assuming 'p' is not null |
|
| |
56 | |
57 | |
58 | |
59 | char *tmp = p; |
60 | |
61 | for (i = 0; i < ndirs; i++) { |
| 7 | Loop condition is true. Entering loop body |
|
62 | register int length = safestrlen (directories[i])((directories[i]) ? strlen(directories[i]) : 0); |
63 | *p = length; |
64 | memcpy (p + 1, directories[i], length); |
| 8 | Null pointer passed as an argument to a 'nonnull' parameter |
|
65 | p += length + 1; |
66 | } |
67 | Data (dpy, tmp, nbytes){ if (dpy->bufptr + (nbytes) <= dpy->bufmax) { memcpy (dpy->bufptr, tmp, (int)nbytes); dpy->bufptr += ((nbytes ) + 3) & ~3; } else _XSend(dpy, tmp, nbytes); }; |
68 | Xfree ((char *) tmp)free(((char *) tmp)); |
69 | retCode = 1; |
70 | } |
71 | else |
72 | retCode = 0; |
73 | |
74 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
75 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
76 | return (retCode); |
77 | } |