Bug Summary

File:hw/xnest/Font.c
Location:line 72, column 10
Description:Access to field 'font_struct' results in a dereference of a null pointer

Annotated Source Code

1/*
2
3Copyright 1993 by Davor Matic
4
5Permission to use, copy, modify, distribute, and sell this software
6and its documentation for any purpose is hereby granted without fee,
7provided that the above copyright notice appear in all copies and that
8both that copyright notice and this permission notice appear in
9supporting documentation. Davor Matic makes no representations about
10the suitability of this software for any purpose. It is provided "as
11is" without express or implied warranty.
12
13*/
14
15#ifdef HAVE_XNEST_CONFIG_H1
16#include <xnest-config.h>
17#endif
18
19#include <X11/X.h>
20#include <X11/Xatom.h>
21#include <X11/Xproto.h>
22#include "misc.h"
23#include "regionstr.h"
24#include <X11/fonts/font.h>
25#include <X11/fonts/fontstruct.h>
26#include "scrnintstr.h"
27
28#include "Xnest.h"
29
30#include "Display.h"
31#include "XNFont.h"
32
33int xnestFontPrivateIndex;
34
35Boolint
36xnestRealizeFont(ScreenPtr pScreen, FontPtr pFont)
37{
38 void *priv;
39 Atom name_atom, value_atom;
40 int nprops;
41 FontPropPtr props;
42 int i;
43 const char *name;
44
45 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL)((xnestFontPrivateIndex) > (pFont)->maxPrivate ? _FontSetNewPrivate
(pFont, xnestFontPrivateIndex, ((void*)0)) : ((((pFont)->
devPrivates[xnestFontPrivateIndex] = (((void*)0))) != 0) || 1
))
;
46
47 name_atom = MakeAtom("FONT", 4, True1);
48 value_atom = 0L;
49
50 nprops = pFont->info.nprops;
51 props = pFont->info.props;
52
53 for (i = 0; i < nprops; i++)
1
Assuming 'i' is < 'nprops'
2
Loop condition is true. Entering loop body
54 if (props[i].name == name_atom) {
3
Taking true branch
55 value_atom = props[i].value;
56 break;
4
Execution continues on line 59
57 }
58
59 if (!value_atom)
5
Assuming 'value_atom' is not equal to 0
6
Taking false branch
60 return False0;
61
62 name = NameForAtom(value_atom);
63
64 if (!name)
7
Assuming 'name' is non-null
8
Taking false branch
65 return False0;
66
67 priv = (void *) malloc(sizeof(xnestPrivFont));
68 FontSetPrivate(pFont, xnestFontPrivateIndex, priv)((xnestFontPrivateIndex) > (pFont)->maxPrivate ? _FontSetNewPrivate
(pFont, xnestFontPrivateIndex, priv) : ((((pFont)->devPrivates
[xnestFontPrivateIndex] = (priv)) != 0) || 1))
;
69
70 xnestFontPriv(pFont)((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->maxPrivate
? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))
->font_struct = XLoadQueryFont(xnestDisplay, name);
71
72 if (!xnestFontStruct(pFont)(((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->
maxPrivate ? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))->font_struct)
)
9
Within the expansion of the macro 'xnestFontStruct':
a
Access to field 'font_struct' results in a dereference of a null pointer
73 return False0;
74
75 return True1;
76}
77
78Boolint
79xnestUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
80{
81 if (xnestFontPriv(pFont)((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->maxPrivate
? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))
) {
82 if (xnestFontStruct(pFont)(((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->
maxPrivate ? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))->font_struct)
)
83 XFreeFont(xnestDisplay, xnestFontStruct(pFont)(((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->
maxPrivate ? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))->font_struct)
);
84 free(xnestFontPriv(pFont)((xnestPrivFont *)((xnestFontPrivateIndex) > (pFont)->maxPrivate
? (void *) 0 : (pFont)->devPrivates[xnestFontPrivateIndex
]))
);
85 FontSetPrivate(pFont, xnestFontPrivateIndex, NULL)((xnestFontPrivateIndex) > (pFont)->maxPrivate ? _FontSetNewPrivate
(pFont, xnestFontPrivateIndex, ((void*)0)) : ((((pFont)->
devPrivates[xnestFontPrivateIndex] = (((void*)0))) != 0) || 1
))
;
86 }
87 return True1;
88}