From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails Date: Fri, 01 Apr 2011 19:21:34 -0700 Organization: UCLA Computer Science Department Message-ID: <4D96882E.3020002@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1301711849 15472 80.91.229.12 (2 Apr 2011 02:37:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 2 Apr 2011 02:37:29 +0000 (UTC) To: 8410@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 02 04:37:24 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 1Q5qiJ-0007Yj-BC for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Apr 2011 04:37:23 +0200 Original-Received: from localhost ([127.0.0.1]:36518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5qiI-0005Oj-SZ for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Apr 2011 22:37:22 -0400 Original-Received: from [140.186.70.92] (port=36031 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5qiB-0005Nv-B6 for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:37:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5qiA-00027y-8Y for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:37:15 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5qiA-00027u-5f for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:37:14 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q5qTR-0000xT-Ob; Fri, 01 Apr 2011 22:22:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert 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 02:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8410 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13017109073657 (code B ref -1); Sat, 02 Apr 2011 02:22:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Apr 2011 02:21:47 +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 1Q5qTD-0000ww-EL for submit@debbugs.gnu.org; Fri, 01 Apr 2011 22:21:47 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q5qTB-0000wk-Hd for submit@debbugs.gnu.org; Fri, 01 Apr 2011 22:21:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5qT5-0000Ni-J9 for submit@debbugs.gnu.org; Fri, 01 Apr 2011 22:21:40 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:54304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5qT5-0000Ne-HE for submit@debbugs.gnu.org; Fri, 01 Apr 2011 22:21:39 -0400 Original-Received: from [140.186.70.92] (port=40246 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q5qT4-00058l-M8 for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:21:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q5qT3-0000NS-Ss for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:21:38 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:42004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q5qT3-0000NL-MY for bug-gnu-emacs@gnu.org; Fri, 01 Apr 2011 22:21:37 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 083D939E80FA for ; Fri, 1 Apr 2011 19:21:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mw8MONsJEWi9 for ; Fri, 1 Apr 2011 19:21:35 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 7110839E80F0 for ; Fri, 1 Apr 2011 19:21:35 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 01 Apr 2011 22:22:01 -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:45572 Archived-At: 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); }