changeset 5809:2f22818d92d4

#'x-store-cutbuffer-internal, correct order of type checks vs. member accesses src/ChangeLog addition: 2014-09-06 Aidan Kehoe <kehoea@parhasard.net> * select-x.c (Fx_store_cutbuffer_internal): Correct the order of XSTRING_{DATA,LENGTH} vs. CHECK_STRING, make sure the former is after the latter, avoiding crashes when passing in arguments of the wrong type, or when ERROR_CHECK_STRUCTURES is defined.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 06 Sep 2014 14:30:15 +0100
parents 1b984807a299
children be31f7878b0d
files src/ChangeLog src/select-x.c
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Aug 22 10:58:09 2014 +0100
+++ b/src/ChangeLog	Sat Sep 06 14:30:15 2014 +0100
@@ -1,3 +1,11 @@
+2014-09-06  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* select-x.c (Fx_store_cutbuffer_internal):
+	Correct the order of XSTRING_{DATA,LENGTH} vs. CHECK_STRING, make
+	sure the former is after the latter, avoiding crashes when passing
+	in arguments of the wrong type, or when ERROR_CHECK_STRUCTURES is
+	defined.
+
 2014-08-03  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* event-stream.c (allocate_command_builder):
--- a/src/select-x.c	Fri Aug 22 10:58:09 2014 +0100
+++ b/src/select-x.c	Sat Sep 06 14:30:15 2014 +0100
@@ -1379,9 +1379,8 @@
   Display *display = DEVICE_X_DISPLAY (d);
   Window window = RootWindow (display, 0); /* Cutbuffers are on frame 0 */
   Atom cut_buffer_atom;
-  const Ibyte *data  = XSTRING_DATA (string);
-  Bytecount bytes = XSTRING_LENGTH (string);
-  Bytecount bytes_remaining;
+  const Ibyte *data;
+  Bytecount bytes, bytes_remaining;
   Bytecount max_bytes = SELECTION_QUANTUM (display);
 #ifdef MULE
   const Ibyte *ptr, *end;
@@ -1393,7 +1392,10 @@
 
   CHECK_CUTBUFFER (cutbuffer);
   CHECK_STRING (string);
+
   cut_buffer_atom = symbol_to_x_atom (d, cutbuffer, 0);
+  data = XSTRING_DATA (string);
+  bytes = XSTRING_LENGTH (string);
 
   if (! cut_buffers_initialized)
     initialize_cut_buffers (display, window);