[Resend: PATCH] dmxConfigCanvasUpdate: Delay dereference until after checking for NULL

Keith Packard keithp at keithp.com
Mon Apr 21 13:18:07 PDT 2014


Alan Coopersmith <alan.coopersmith at oracle.com> writes:

> 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 at oracle.com>

Something is screwy with this patch -- git says:

Applying: dmxConfigCanvasUpdate: Delay dereference until after checking for NULL
fatal: corrupt patch at line 16

> ---
>   hw/dmx/config/xdmxconfig.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> 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)
> -- 
> 1.7.9.2
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140421/7f643f3b/attachment.sig>


More information about the xorg-devel mailing list