]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix selection preservation bug when USE_XCB
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Aug 2022 18:11:30 +0000 (11:11 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Aug 2022 18:14:17 +0000 (11:14 -0700)
* src/xterm.c (x_preserve_selections) [USE_XCB]: Fix bug: use of
wrong ‘tem’ value.  Found by GCC -Wanalyzer-use-of-uninitialized-value.
Move decl of local to make the (former) bug more obvious.

src/xterm.c

index 6cf44e162b17bee186e0156b2ecc04a3da204602..5047f3066be1ae21d5f03fcb305ec43e36d5882b 100644 (file)
@@ -29140,7 +29140,7 @@ void
 x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
                       Lisp_Object current_owner)
 {
-  Lisp_Object tail, frame, new_owner, tem;
+  Lisp_Object tail, frame, new_owner;
   Time timestamp;
   Window *owners;
   Atom *names;
@@ -29170,7 +29170,7 @@ x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
 
   FOR_EACH_TAIL_SAFE (tail)
     {
-      tem = XCAR (tail);
+      Lisp_Object tem = XCAR (tail);
       ++nowners;
 
       /* The selection is really lost (since we cannot find a new
@@ -29204,7 +29204,7 @@ x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
 
       FOR_EACH_TAIL_SAFE (tail)
        {
-         tem = XCAR (tail);
+         Lisp_Object tem = XCAR (tail);
 
          /* Now check if we still don't own that selection, which can
             happen if another program set itself as the owner.  */
@@ -29224,9 +29224,10 @@ x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
 
       FOR_EACH_TAIL_SAFE (tail)
        {
+         Lisp_Object tem = XCAR (tail);
+
          reply = xcb_get_selection_owner_reply (dpyinfo->xcb_connection,
                                                 cookies[nowners++], &error);
-
          if (reply)
            owners[nowners - 1] = reply->owner;
          else
@@ -29256,7 +29257,7 @@ x_preserve_selections (struct x_display_info *dpyinfo, Lisp_Object lost,
 
       FOR_EACH_TAIL_SAFE (tail)
        {
-         tem = XCAR (tail);
+         Lisp_Object tem = XCAR (tail);
 
          /* If the selection isn't owned by us anymore, note that the
             selection was lost.  */