aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorPaul Eggert2014-09-07 12:47:28 -0700
committerPaul Eggert2014-09-07 12:47:28 -0700
commitbee407185922627a073b5fb57daae56043e689b0 (patch)
treefd2058485b8633e7698d84e0aeaa1ba63ec556ac /src/xselect.c
parenteee8ec84426af080d82f37ab0280bd96ae6091bd (diff)
downloademacs-bee407185922627a073b5fb57daae56043e689b0.tar.gz
emacs-bee407185922627a073b5fb57daae56043e689b0.zip
Adjust drag-and-drop fix when window is above top.
* xselect.c (x_fill_property_data): Don't let sign bit of negative XCDR bleed into XCAR's encoded value. Improve checks for out-of-range data while we're at it. Fixes: debbugs:18383
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/xselect.c b/src/xselect.c
index ed359849be4..6a54b397626 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2300,22 +2300,20 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2300 2300
2301 if (INTEGERP (o) || FLOATP (o) || CONSP (o)) 2301 if (INTEGERP (o) || FLOATP (o) || CONSP (o))
2302 { 2302 {
2303 if (CONSP (o) && INTEGERP (XCAR (o)) && INTEGERP (XCDR (o))) 2303 if (CONSP (o)
2304 && RANGED_INTEGERP (X_LONG_MIN >> 16, XCAR (o), X_LONG_MAX >> 16)
2305 && RANGED_INTEGERP (- (1 << 15), XCDR (o), -1))
2304 { 2306 {
2305 intmax_t v1 = XINT (XCAR (o)); 2307 long v1 = XINT (XCAR (o));
2306 intmax_t v2 = XINT (XCDR (o)); 2308 long v2 = XINT (XCDR (o));
2307 /* cons_to_signed does not handle negative values for v2. 2309 /* cons_to_signed does not handle negative values for v2.
2308 For XDnd, v2 might be y of a window, and can be negative. 2310 For XDnd, v2 might be y of a window, and can be negative.
2309 The XDnd spec. is not explicit about negative values, 2311 The XDnd spec. is not explicit about negative values,
2310 but lets do what it says. 2312 but let's assume negative v2 is sent modulo 2**16. */
2311 */ 2313 val = (v1 << 16) | (v2 & 0xffff);
2312 if (v1 < 0 || v2 < 0)
2313 val = (v1 << 16) | v2;
2314 else
2315 val = cons_to_signed (o, LONG_MIN, LONG_MAX);
2316 } 2314 }
2317 else 2315 else
2318 val = cons_to_signed (o, LONG_MIN, LONG_MAX); 2316 val = cons_to_signed (o, X_LONG_MIN, X_LONG_MAX);
2319 } 2317 }
2320 else if (STRINGP (o)) 2318 else if (STRINGP (o))
2321 { 2319 {
@@ -2335,7 +2333,7 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2335 } 2333 }
2336 else if (format == 16) 2334 else if (format == 16)
2337 { 2335 {
2338 if (SHRT_MIN <= val && val <= SHRT_MAX) 2336 if (X_SHRT_MIN <= val && val <= X_SHRT_MAX)
2339 *d16++ = val; 2337 *d16++ = val;
2340 else 2338 else
2341 error ("Out of 'short' range"); 2339 error ("Out of 'short' range");