GNU bug report logs - #8410
make_invisible_cursor returns garbage if XCreateBitmapFromData fails

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Sat, 2 Apr 2011 02:22:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Subject: bug#8410: closed (fix installed in trunk)
Date: Wed, 06 Apr 2011 05:48:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 8410 <at> debbugs.gnu.org.

-- 
8410: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8410
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 8401-done <at> debbugs.gnu.org, 8410-done <at> debbugs.gnu.org
Subject: fix installed in trunk
Date: Tue, 05 Apr 2011 22:47:16 -0700
I committed the previously-mentioned fix
as part of the merge to the trunk in bzr 103841.

[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: make_invisible_cursor returns garbage if XCreateBitmapFromData fails
Date: Fri, 01 Apr 2011 19:21:34 -0700
I found this bug via static analysis, using GCC 4.6.0's warnings.
src/xfns.c's make_invisible_cursor returns a garbage value if
XCreateBitmapFromData fails.  I plan to fix it as follows.
I don't know that returning 0 fixes the bug, so I'd like someone
who's expert in this area to look at this.  Since the patch replaces
undefined behavior with defined behavior it isn't likely to be
introducing a bug, so it shouldn't hurt to install the patch.

* xfns.c (make_invisible_cursor): Don't return garbage
if XCreateBitmapFromData fails.
=== modified file 'src/xfns.c'
--- src/xfns.c	2011-04-01 20:30:45 +0000
+++ src/xfns.c	2011-04-01 23:01:33 +0000
@@ -855,19 +855,20 @@
   static char const no_data[] = { 0 };
   Pixmap pix;
   XColor col;
-  Cursor c;
+  Cursor c = 0;

   x_catch_errors (dpy);
   pix = XCreateBitmapFromData (dpy, FRAME_X_DISPLAY_INFO (f)->root_window,
                                no_data, 1, 1);
   if (! x_had_errors_p (dpy) && pix != None)
     {
+      Cursor pixc;
       col.pixel = 0;
       col.red = col.green = col.blue = 0;
       col.flags = DoRed | DoGreen | DoBlue;
-      c = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
-      if (x_had_errors_p (dpy) || c == None)
-        c = 0;
+      pixc = XCreatePixmapCursor (dpy, pix, pix, &col, &col, 0, 0);
+      if (! x_had_errors_p (dpy) && pixc != None)
+        c = pixc;
       XFreePixmap (dpy, pix);
     }





This bug report was last modified 14 years and 53 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.