Bug Summary

File:src/xlibi18n/utf8Wrap.c
Location:line 106, column 10
Description:Access to field 'methods' results in a dereference of a null pointer (loaded from variable 'fs')

Annotated Source Code

1/*
2
3Copyright 1991, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included
12in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall
23not be used in advertising or otherwise to promote the sale, use or
24other dealings in this Software without prior written authorization
25from The Open Group.
26
27*/
28/*
29 * Copyright 1991 by the Open Software Foundation
30 *
31 * Permission to use, copy, modify, distribute, and sell this software and its
32 * documentation for any purpose is hereby granted without fee, provided that
33 * the above copyright notice appear in all copies and that both that
34 * copyright notice and this permission notice appear in supporting
35 * documentation, and that the name of Open Software Foundation
36 * not be used in advertising or publicity pertaining to distribution of the
37 * software without specific, written prior permission. Open Software
38 * Foundation makes no representations about the suitability of this
39 * software for any purpose. It is provided "as is" without express or
40 * implied warranty.
41 *
42 * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
43 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
44 * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN BE
45 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
46 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
47 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
48 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 *
50 * M. Collins OSF
51 */
52/*
53 * Copyright 2000 by Bruno Haible
54 *
55 * Permission to use, copy, modify, distribute, and sell this software
56 * and its documentation for any purpose is hereby granted without fee,
57 * provided that the above copyright notice appear in all copies and
58 * that both that copyright notice and this permission notice appear
59 * in supporting documentation, and that the name of Bruno Haible not
60 * be used in advertising or publicity pertaining to distribution of the
61 * software without specific, written prior permission. Bruno Haible
62 * makes no representations about the suitability of this software for
63 * any purpose. It is provided "as is" without express or implied
64 * warranty.
65 *
66 * Bruno Haible DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
67 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
68 * NO EVENT SHALL Bruno Haible BE LIABLE FOR ANY SPECIAL, INDIRECT OR
69 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
70 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
71 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
72 * OR PERFORMANCE OF THIS SOFTWARE.
73 */
74
75#ifdef HAVE_CONFIG_H1
76#include <config.h>
77#endif
78#include "Xlibint.h"
79#include "Xlcint.h"
80
81void
82Xutf8DrawText(
83 Display *dpy,
84 Drawable d,
85 GC gc,
86 int x,
87 int y,
88 XmbTextItem *text_items,
89 int nitems)
90{
91 register XFontSet fs = NULL((void*)0);
1
'fs' initialized to a null pointer value
92 register XmbTextItem *p = text_items;
93 register int i = nitems;
94 register int esc;
95
96 /* ignore leading items with no fontset */
97 while (i && !p->font_set) {
2
Loop condition is true. Entering loop body
3
Loop condition is false. Execution continues on line 102
98 i--;
99 p++;
100 }
101
102 for (; --i >= 0; p++) {
4
Loop condition is true. Entering loop body
103 if (p->font_set)
5
Taking false branch
104 fs = p->font_set;
105 x += p->delta;
106 esc = (*fs->methods->utf8_draw_string) (dpy, d, fs, gc, x, y,
6
Access to field 'methods' results in a dereference of a null pointer (loaded from variable 'fs')
107 p->chars, p->nchars);
108 if (!esc)
109 esc = fs->methods->utf8_escapement (fs, p->chars, p->nchars);
110 x += esc;
111 }
112}
113
114void
115Xutf8DrawString(
116 Display *dpy,
117 Drawable d,
118 XFontSet font_set,
119 GC gc,
120 int x,
121 int y,
122 _Xconstconst char *text,
123 int text_len)
124{
125 (void)(*font_set->methods->utf8_draw_string) (dpy, d, font_set, gc, x, y,
126 text, text_len);
127}
128
129
130void
131Xutf8DrawImageString(
132 Display *dpy,
133 Drawable d,
134 XFontSet font_set,
135 GC gc,
136 int x,
137 int y,
138 _Xconstconst char *text,
139 int text_len)
140{
141 (*font_set->methods->utf8_draw_image_string) (dpy, d, font_set, gc, x, y,
142 text, text_len);
143}
144
145int
146Xutf8TextEscapement(
147 XFontSet font_set,
148 _Xconstconst char *text,
149 int text_len)
150{
151 return (*font_set->methods->utf8_escapement) (font_set, text, text_len);
152}
153
154int
155Xutf8TextExtents(
156 XFontSet font_set,
157 _Xconstconst char *text,
158 int text_len,
159 XRectangle *overall_ink_extents,
160 XRectangle *overall_logical_extents)
161{
162 return (*font_set->methods->utf8_extents) (font_set, text, text_len,
163 overall_ink_extents,
164 overall_logical_extents);
165}
166
167Statusint
168Xutf8TextPerCharExtents(
169 XFontSet font_set,
170 _Xconstconst char *text,
171 int text_len,
172 XRectangle *ink_extents_buffer,
173 XRectangle *logical_extents_buffer,
174 int buffer_size,
175 int *num_chars,
176 XRectangle *max_ink_extents,
177 XRectangle *max_logical_extents)
178{
179 return (*font_set->methods->utf8_extents_per_char)
180 (font_set, text, text_len,
181 ink_extents_buffer, logical_extents_buffer,
182 buffer_size, num_chars, max_ink_extents, max_logical_extents);
183}