diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-04-21 15:18:45 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-04-21 20:54:22 -0700 |
commit | 935ea0d7b5e18ad8f22ee074a08cbdc7390d0f5d (patch) | |
tree | d163ae74007b9b976d9142febd2472064091f3e4 /hw/dmx/config/xdmxconfig.c | |
parent | 983e30361f49a67252d0b5d82630e70724d69dbf (diff) |
dmxConfigCanvasUpdate: Delay dereference until after checking for NULL
Flagged by cppcheck 1.64:
[hw/dmx/config/xdmxconfig.c:306] -> [hw/dmx/config/xdmxconfig.c:323]:
(warning) Possible null pointer dereference: fs - otherwise
it is redundant to check it against null.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'hw/dmx/config/xdmxconfig.c')
-rw-r--r-- | hw/dmx/config/xdmxconfig.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/dmx/config/xdmxconfig.c b/hw/dmx/config/xdmxconfig.c index 2b7b9683b..0540d0173 100644 --- a/hw/dmx/config/xdmxconfig.c +++ b/hw/dmx/config/xdmxconfig.c @@ -303,7 +303,6 @@ dmxConfigCanvasUpdate(void) fs = XQueryFont(dpy, gcontext); for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) { int x, y, len; - int xo = 3, yo = fs->ascent + fs->descent + 2; GC gc; if (pt->type != dmxConfigDisplay) @@ -321,6 +320,8 @@ dmxConfigCanvasUpdate(void) y = dmxConfigWidgetHeight - 1; XDrawRectangle(dpy, win, gc, x, y, w, h); if (fs && len) { + int xo = 3, yo = fs->ascent + fs->descent + 2; + while (len && XTextWidth(fs, pt->display->name, len) >= w - 2 * xo) --len; if (len) |