changeset 97869:455b25c4ebc2

(Fw16_set_clipboard_data): Don't encode text if clipboard is unavailable. Set dst to NULL if it doesn't point to malloc'ed data. (Fw16_get_clipboard_data): Initialize htext to NULL, to avoid passing random values to xfree.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 30 Aug 2008 12:32:16 +0000
parents 63c917af418b
children f4fb7fe0f9b3
files src/w16select.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/w16select.c	Sat Aug 30 12:15:06 2008 +0000
+++ b/src/w16select.c	Sat Aug 30 12:32:16 2008 +0000
@@ -500,6 +500,9 @@
 
   BLOCK_INPUT;
 
+  if (!open_clipboard ())
+    goto error;
+
   nbytes = SBYTES (string);
   src = SDATA (string);
 
@@ -515,6 +518,7 @@
 	 will have to convert it to DOS CR-LF style.  */
       no_crlf_conversion = 0;
       Vlast_coding_system_used = Qraw_text;
+      dst = NULL;	/* so we don't try to free a random pointer */
     }
   else
     {
@@ -541,9 +545,6 @@
       src = dst;
     }
 
-  if (!open_clipboard ())
-    goto error;
-
   ok = empty_clipboard ()
     && ((put_status
 	 = set_clipboard_data (CF_OEMTEXT, src, nbytes, no_crlf_conversion))
@@ -595,7 +596,7 @@
      Lisp_Object frame;
 {
   unsigned data_size, truelen;
-  unsigned char *htext;
+  unsigned char *htext = NULL;
   Lisp_Object ret = Qnil;
   int no_crlf_conversion, require_decoding = 0;