From: Paul Eggert <eggert@cs.ucla.edu>
To: 8410@debbugs.gnu.org
Subject: bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails
Date: Fri, 01 Apr 2011 19:21:34 -0700 [thread overview]
Message-ID: <4D96882E.3020002@cs.ucla.edu> (raw)
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);
}
next reply other threads:[~2011-04-02 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-02 2:21 Paul Eggert [this message]
2011-04-02 6:45 ` bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails Jan Djärv
2011-04-06 5:47 ` bug#8410: fix installed in trunk Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D96882E.3020002@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=8410@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.