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

2012-01-10 Thread Aurélien Aptel
On Tue, Jan 10, 2012 at 10:04 PM, Martti Kühne  wrote:
> 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?

Good catch. Let's go with the former.



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

2012-01-10 Thread Martti Kühne
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
@@ -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
@@ -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