[dev] st: equivalent fixes: st-sel-fix

From: Martti Kühne <mysatyre_AT_gmail.com>
Date: Tue, 10 Jan 2012 22:04:13 +0100

hello list

I announced a fix on irc earlier today for a recurring problem when using st
on a daily basis, and looking further into the issue, I found there are,
afaict two seemingly identically valid fixes for the problem:

--- st/st.c 2011-11-02 21:24:08.893374099 +0100
+++ st-selfix/st.c 2012-01-10 21:27:24.053424322 +0100
_AT_@ -547,7 +545,7 @@
                                 XA_ATOM, 32, PropModeReplace,
                                 (unsigned char *) &string, 1);
                 xev.property = xsre->property;
- } else if(xsre->target == sel.xtarget) {
+ } else if(xsre->target == sel.xtarget && sel.clip != NULL) {
                 XChangeProperty(xsre->display, xsre->requestor, xsre->property,
                                 xsre->target, 8, PropModeReplace,
                                 (unsigned char *) sel.clip, strlen(sel.clip));

and

--- st/st.c 2011-11-02 21:24:08.893374099 +0100
+++ st-selfix2/st.c 2012-01-10 21:35:00.131451765 +0100
_AT_@ -493,8 +493,8 @@
                                 *ptr++ = '\n';
                 }
                 *ptr = 0;
+ xsetsel(str);
         }
- xsetsel(str);
 }
 
 void

anyway, the problem is that XChangeProperty() will cause a segfault if it gets
NULL - or strlen. I'm slightly in favor of the former, as it will allow
sel.clip to be any value at any time, which is good. Thoughts?

Which reminds me, I just wanted to paste the diffs into st where I'm writing
this email and it seems copy/pasting doesn't work well with newlines. I might
be back later or tomorrow with another one. =)

cheers!
mar77i
Received on Tue Jan 10 2012 - 22:04:13 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 10 2012 - 22:12:04 CET