emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 21c8a9d944: Fix crash while converting empty vector to X data


From: Po Lu
Subject: master 21c8a9d944: Fix crash while converting empty vector to X data
Date: Sun, 4 Sep 2022 21:51:40 -0400 (EDT)

branch: master
commit 21c8a9d944b37e431f56738c10a9fa7a75f4c3a9
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix crash while converting empty vector to X data
    
    * src/xselect.c (lisp_data_to_selection_data): Assume an empty
    vector represents INTEGER data, instead of blindly trying to
    aref it's first element.
---
 src/xselect.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/xselect.c b/src/xselect.c
index 74d762f305..66782d4172 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2017,7 +2017,17 @@ lisp_data_to_selection_data (struct x_display_info 
*dpyinfo,
       ptrdiff_t i;
       ptrdiff_t size = ASIZE (obj);
 
-      if (SYMBOLP (AREF (obj, 0)))
+      if (!size)
+       {
+         /* This vector is empty and of unknown type.  Assume that it
+            is a vector of integers.  */
+
+         cs->data = NULL;
+         cs->format = 32;
+         cs->size = 0;
+         type = QINTEGER;
+       }
+      else if (SYMBOLP (AREF (obj, 0)))
        /* This vector is an ATOM set */
        {
          void *data;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]