| File: | hw/xnest/Font.c |
| Location: | line 83, column 37 |
| Description: | Access to field 'font_struct' results in a dereference of a null pointer |
| 1 | /* | |||||
| 2 | ||||||
| 3 | Copyright 1993 by Davor Matic | |||||
| 4 | ||||||
| 5 | Permission to use, copy, modify, distribute, and sell this software | |||||
| 6 | and its documentation for any purpose is hereby granted without fee, | |||||
| 7 | provided that the above copyright notice appear in all copies and that | |||||
| 8 | both that copyright notice and this permission notice appear in | |||||
| 9 | supporting documentation. Davor Matic makes no representations about | |||||
| 10 | the suitability of this software for any purpose. It is provided "as | |||||
| 11 | is" 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 | ||||||
| 33 | int xnestFontPrivateIndex; | |||||
| 34 | ||||||
| 35 | Boolint | |||||
| 36 | xnestRealizeFont(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++) | |||||
| 54 | if (props[i].name == name_atom) { | |||||
| 55 | value_atom = props[i].value; | |||||
| 56 | break; | |||||
| 57 | } | |||||
| 58 | ||||||
| 59 | if (!value_atom) | |||||
| 60 | return False0; | |||||
| 61 | ||||||
| 62 | name = NameForAtom(value_atom); | |||||
| 63 | ||||||
| 64 | if (!name) | |||||
| 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)) | |||||
| 73 | return False0; | |||||
| 74 | ||||||
| 75 | return True1; | |||||
| 76 | } | |||||
| 77 | ||||||
| 78 | Boolint | |||||
| 79 | xnestUnrealizeFont(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 | } |