From 6e6eb3e6c0a6e687ed32b643da5436d0d03d8c22 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Tue, 3 Feb 2004 23:44:47 +0000 Subject: * w32select.c (Fw32_set_clipboard_data): Make coding iso2022 safe. * w32fns.c (x_to_w32_font): Likewise. --- src/w32select.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/w32select.c') diff --git a/src/w32select.c b/src/w32select.c index 6533f4b660d..940cce35772 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -212,6 +212,11 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, } coding.src_multibyte = 1; coding.dst_multibyte = 0; + /* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in + encode_coding_iso2022 trying to dereference a null pointer. */ + coding.composing = COMPOSITION_DISABLED; + if (coding.type == coding_type_iso2022) + coding.flags |= CODING_FLAG_ISO_SAFE; Vnext_selection_coding_system = Qnil; coding.mode |= CODING_MODE_LAST_BLOCK; bufsize = encoding_buffer_size (&coding, nbytes); -- cgit v1.2.1 From b3897dc11f35833b588481c7acf2c4bc5f326687 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Sun, 18 Apr 2004 18:34:03 +0000 Subject: (Fw32_set_clipboard_data): Get sequence number after closing the clipboard. --- src/w32select.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/w32select.c') diff --git a/src/w32select.c b/src/w32select.c index 940cce35772..0c8849c7be6 100644 --- a/src/w32select.c +++ b/src/w32select.c @@ -259,11 +259,18 @@ DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); + CloseClipboard (); + + /* Common sense says to read the sequence number inside the + OpenClipboard/ CloseClipboard block to avoid race conditions + where another app puts something on the clipboard straight after + us. But experience suggests that the sequence number from the + SetClipboardData is not allocated until we close the clipboard! + Since clipboard operations are normally user-driven, the race + condition is probably not going to really happen. */ if (clipboard_sequence_fn) last_clipboard_sequence_number = clipboard_sequence_fn (); - CloseClipboard (); - if (ok) goto done; error: -- cgit v1.2.1