From: Alan Coopersmith Date: Mon, 21 Apr 2014 22:18:45 +0000 (-0700) Subject: dmxConfigCanvasUpdate: Delay dereference until after checking for NULL X-Git-Tag: upstream/1.16~100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=935ea0d7b5e18ad8f22ee074a08cbdc7390d0f5d;p=platform%2Fupstream%2Fxorg-server.git 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 Reviewed-by: Keith Packard Signed-off-by: Keith Packard --- diff --git a/hw/dmx/config/xdmxconfig.c b/hw/dmx/config/xdmxconfig.c index 2b7b968..0540d01 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)