commit/XEmacs: kehoea: #'x-store-cutbuffer-internal, correct order of type checks vs. member accesses

[email protected] Sat, 06 Sep 2014 13:30:43 -0000
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
1 new commit in XEmacs:

https://bitbucket.org/xemacs/xemacs/commits/2f22818d92d4/
Changeset:   2f22818d92d4
User:        kehoea
Date:        2014-09-06 15:30:15
Summary:     #'x-store-cutbuffer-internal, correct order of type checks vs. member accesses

src/ChangeLog addition:

2014-09-06  Aidan Kehoe  <[email protected]>

	* 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.
Affected #:  2 files

diff -r 1b984807a2990fb31c0f6ae2b7c6bd833ed36394 -r 2f22818d92d42460586af6894cdbc4166cba3e6b src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2014-09-06  Aidan Kehoe  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* event-stream.c (allocate_command_builder):

diff -r 1b984807a2990fb31c0f6ae2b7c6bd833ed36394 -r 2f22818d92d42460586af6894cdbc4166cba3e6b src/select-x.c
--- a/src/select-x.c
+++ b/src/select-x.c
@@ -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);

Repository URL: https://bitbucket.org/xemacs/xemacs/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.