summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-10-20 01:11:21 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-10-28 20:29:16 -0700
commit455c2f3715456fd88c2741bd2028a9f0a702bb28 (patch)
tree016e6ec804e8270787ee3c8078ce1c3a36bc926c
parent7544a9eb35d5850ae2e68d8cdab50f25ce7cd5d9 (diff)
Don't dereference xkb pointer until after checking it for NULL
Some compilers can perform mind-twistingly evil optimizations if you check for NULL after using it, others just let you segv. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Ran Benita <ran234@gmail.com>
-rw-r--r--src/xkmout.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/xkmout.c b/src/xkmout.c
index 8f54e14..39655be 100644
--- a/src/xkmout.c
+++ b/src/xkmout.c
@@ -136,11 +136,11 @@ SizeXKMVirtualMods(XkbFileInfo *result, XkmInfo *info,
register unsigned i, bit;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->names) || (!xkb->server)) {
_XkbLibError(_XkbErrMissingVMods, "SizeXKMVirtualMods", 0);
return 0;
}
+ dpy = xkb->dpy;
bound = named = 0;
for (i = nBound = nNamed = szNames = 0, bit = 1; i < XkbNumVirtualMods;
i++, bit <<= 1) {
@@ -207,11 +207,11 @@ SizeXKMKeycodes(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
Display *dpy;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->names) || (!xkb->names->keys)) {
_XkbLibError(_XkbErrMissingNames, "SizeXKMKeycodes", 0);
return 0;
}
+ dpy = xkb->dpy;
kcName = xkb->names->keycodes;
size += 4; /* min and max keycode */
size += xkmSizeCountedAtomString(dpy, kcName);
@@ -271,11 +271,11 @@ SizeXKMKeyTypes(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
char *name;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->map) || (!xkb->map->types)) {
_XkbLibError(_XkbErrMissingTypes, "SizeXKBKeyTypes", 0);
return 0;
}
+ dpy = xkb->dpy;
if (xkb->map->num_types < XkbNumRequiredTypes) {
_XkbLibError(_XkbErrMissingReqTypes, "SizeXKBKeyTypes", 0);
return 0;
@@ -390,11 +390,11 @@ SizeXKMCompatMap(XkbFileInfo *result, XkmInfo *info,
Display *dpy;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->compat) || (!xkb->compat->sym_interpret)) {
_XkbLibError(_XkbErrMissingCompatMap, "SizeXKMCompatMap", 0);
return 0;
}
+ dpy = xkb->dpy;
if (xkb->names)
name = XkbAtomGetString(dpy, xkb->names->compat);
else
@@ -490,11 +490,11 @@ SizeXKMSymbols(XkbFileInfo *result, XkmInfo *info,
char *name;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->map) || ((!xkb->map->syms))) {
_XkbLibError(_XkbErrMissingSymbols, "SizeXKMSymbols", 0);
return 0;
}
+ dpy = xkb->dpy;
if (xkb->names && (xkb->names->symbols != None))
name = XkbAtomGetString(dpy, xkb->names->symbols);
else
@@ -673,11 +673,11 @@ SizeXKMIndicators(XkbFileInfo *result, XkmInfo *info,
register unsigned i, nLEDs;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((xkb == NULL) || (xkb->indicators == NULL)) {
/* _XkbLibError(_XkbErrMissingIndicators,"SizeXKMIndicators",0);*/
return 0;
}
+ dpy = xkb->dpy;
nLEDs = 0;
size = 8; /* number of indicator maps/physical indicators */
if (xkb->indicators != NULL) {
@@ -830,9 +830,9 @@ SizeXKMGeometry(XkbFileInfo *result, xkmSectionInfo *toc, int *offset_inout)
unsigned size;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->geom))
return 0;
+ dpy = xkb->dpy;
geom = xkb->geom;
size = xkmSizeCountedAtomString(dpy, geom->name);
size += SIZEOF(xkmGeometryDesc);
@@ -1067,9 +1067,9 @@ WriteXKMGeometry(FILE *file, XkbFileInfo *result)
unsigned tmp, size = 0;
xkb = result->xkb;
- dpy = xkb->dpy;
if ((!xkb) || (!xkb->geom))
return 0;
+ dpy = xkb->dpy;
geom = xkb->geom;
wire.width_mm = geom->width_mm;
wire.height_mm = geom->height_mm;