From unknown Mon Jun 23 04:12:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails 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: To: 8410@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13017109073657 (code B ref -1); Sat, 02 Apr 2011 02:22:01 +0000 Received: (at submit) by debbugs.gnu.org; 2 Apr 2011 02:21:47 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 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 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 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 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 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 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) 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) Message-ID: <4D96882E.3020002@cs.ucla.edu> Date: Fri, 01 Apr 2011 19:21:34 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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-Received-From: 199.232.76.165 X-Spam-Score: -4.7 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) 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); } From unknown Mon Jun 23 04:12:25 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8410: make_invisible_cursor returns garbage if XCreateBitmapFromData fails 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: To: Paul Eggert Cc: 8410@debbugs.gnu.org Received: via spool by 8410-submit@debbugs.gnu.org id=B8410.130172671725320 (code B ref 8410); Sat, 02 Apr 2011 06:46:02 +0000 Received: (at 8410) by debbugs.gnu.org; 2 Apr 2011 06:45:17 +0000 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 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 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" 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 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) Message-ID: <4D96C5F2.9020802@swipnet.se> Date: Sat, 02 Apr 2011 08:45:06 +0200 From: Jan =?UTF-8?Q?Dj=C3=A4rv?= 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 MIME-Version: 1.0 References: <4D96882E.3020002@cs.ucla.edu> In-Reply-To: <4D96882E.3020002@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) 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); > } > > > > From unknown Mon Jun 23 04:12:25 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#8410: closed (fix installed in trunk) Message-ID: References: <4D9BFE64.8090502@cs.ucla.edu> <4D96882E.3020002@cs.ucla.edu> X-Gnu-PR-Message: they-closed 8410 X-Gnu-PR-Package: emacs Reply-To: 8410@debbugs.gnu.org Date: Wed, 06 Apr 2011 05:48:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1302068882-24806-1" This is a multi-part message in MIME format... ------------=_1302068882-24806-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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@debbugs.gnu.org. --=20 8410: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D8410 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1302068882-24806-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 8410-done) by debbugs.gnu.org; 6 Apr 2011 05:47:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7Laj-0006RX-NN for submit@debbugs.gnu.org; Wed, 06 Apr 2011 01:47:46 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7Lah-0006RF-DP; Wed, 06 Apr 2011 01:47:44 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 71E7339E80F0; Tue, 5 Apr 2011 22:47:37 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu 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 bpiraXhtX56i; Tue, 5 Apr 2011 22:47:37 -0700 (PDT) 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 2BF8039E80B1; Tue, 5 Apr 2011 22:47:37 -0700 (PDT) Message-ID: <4D9BFE64.8090502@cs.ucla.edu> Date: Tue, 05 Apr 2011 22:47:16 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: 8401-done@debbugs.gnu.org, 8410-done@debbugs.gnu.org Subject: fix installed in trunk Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 8410-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) I committed the previously-mentioned fix as part of the merge to the trunk in bzr 103841. ------------=_1302068882-24806-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 2 Apr 2011 02:21:47 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 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 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 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 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 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 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) 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) Message-ID: <4D96882E.3020002@cs.ucla.edu> Date: Fri, 01 Apr 2011 19:21:34 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: make_invisible_cursor returns garbage if XCreateBitmapFromData fails Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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-Received-From: 199.232.76.165 X-Spam-Score: -4.7 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) 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); } ------------=_1302068882-24806-1--