From: Eli Zaretskii Date: Sat, 30 Aug 2008 12:32:59 +0000 (+0000) Subject: (Fw16_set_clipboard_data): Don't encode text if clipboard is unavailable. X-Git-Tag: emacs-pretest-23.0.90~3138 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1b912a3b4e5e763c24ef1af6528f6ebe53f4744a;p=emacs.git (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. --- diff --git a/src/ChangeLog b/src/ChangeLog index fc64f7e33f8..f02db31f0b7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2008-08-30 Eli Zaretskii + * w16select.c (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. + * dispnew.c (init_display): Set `tty's association in frame's parameters alist to the name of the terminal device, if that is known. diff --git a/src/w16select.c b/src/w16select.c index 2a2b05f72e5..9498d7adfe8 100644 --- a/src/w16select.c +++ b/src/w16select.c @@ -500,6 +500,9 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat BLOCK_INPUT; + if (!open_clipboard ()) + goto error; + nbytes = SBYTES (string); src = SDATA (string); @@ -515,6 +518,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat 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 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat 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 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat 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;