From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Newsgroups: gmane.emacs.bugs Subject: bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails Date: Sat, 02 Apr 2011 08:45:06 +0200 Message-ID: <4D96C5F2.9020802@swipnet.se> References: <4D96882E.3020002@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1301728061 8819 80.91.229.12 (2 Apr 2011 07:07:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 2 Apr 2011 07:07:41 +0000 (UTC) Cc: 8410@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 02 09:07:37 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5uvm-0005Ut-AU for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2011 09:07:34 +0200 Original-Received: from localhost ([127.0.0.1]:43404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5uvl-0008St-E8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2011 03:07:33 -0400 Original-Received: from [140.186.70.92] (port=58019 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5uvU-0008SR-8M for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2011 03:07:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5uvT-0005bF-60 for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2011 03:07:16 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5uvT-0005bB-4T for bug-gnu-emacs@gnu.org; Sat, 02 Apr 2011 03:07:15 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q5uaw-0006bQ-Kw; Sat, 02 Apr 2011 02:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Apr 2011 06:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8410-submit@debbugs.gnu.org id=B8410.130172671725320 (code B ref 8410); Sat, 02 Apr 2011 06:46:02 +0000 Original-Received: (at 8410) by debbugs.gnu.org; 2 Apr 2011 06:45:17 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5uaD-0006aL-8V for submit@debbugs.gnu.org; Sat, 02 Apr 2011 02:45:17 -0400 Original-Received: from smtprelay-h22.telenor.se ([195.54.99.197]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5uaB-0006a8-7A for 8410@debbugs.gnu.org; Sat, 02 Apr 2011 02:45:16 -0400 Original-Received: from ipb3.telenor.se (ipb3.telenor.se [195.54.127.166]) by smtprelay-h22.telenor.se (Postfix) with ESMTP id 04289D674 for <8410@debbugs.gnu.org>; Sat, 2 Apr 2011 08:45:08 +0200 (CEST) X-SENDER-IP: [85.225.45.100] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai5LAOrElk1V4S1kPGdsb2JhbACESIRJnFALAQEBATcysReQPYEoeIJUdwSQfoIuhmA X-IronPort-AV: E=Sophos;i="4.63,287,1299452400"; d="scan'208";a="1124904" Original-Received: from c-642de155.25-1-64736c10.cust.bredbandsbolaget.se (HELO coolsville.localdomain) ([85.225.45.100]) by ipb3.telenor.se with ESMTP; 02 Apr 2011 08:45:08 +0200 Original-Received: from [172.20.199.13] (zeplin [172.20.199.13]) by coolsville.localdomain (Postfix) with ESMTPSA id D6D0C7FA05A; Sat, 2 Apr 2011 08:45:07 +0200 (CEST) User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <4D96882E.3020002@cs.ucla.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 02 Apr 2011 02:46:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45573 Archived-At: It looks OK. But there are lots of places in Emacs where errors and return values from X calls are not checked. make_gc in the same file comes to mind. If anything goes wrong there, emacs crashes on an X protocol error message. If there is an error here it means the X server is out of memory, so Emacs will probably crash on another X call later on anyway. But if you want to get rid of the gcc warning, your patch is correct. If Emacs somehow survives a bit longer, returning 0 means that the invisible cursor functionality will not work, the cursor will not become invisible. Jan D. Paul Eggert skrev 2011-04-02 04.21: > 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); > } > > > >