$NetBSD: patch-al,v 1.2 2025/10/20 18:32:10 vins Exp $

* Fix 64-bit crash inside rxvt_selection_send().
  See https://gnats.netbsd.org/33680

--- src/screen.c.orig	2003-03-23 16:56:06.000000000 +0000
+++ src/screen.c
@@ -3211,9 +3211,9 @@ rxvt_selection_adjust_kanji(rxvt_t *r)
 	    && IS_MULTI1(r->screen.rend[r1][c1 - 1]))
 	    r->selection.beg.col--;
     }
-    if (r->selection.end.col < r->TermWin.ncol) {
+    c1 = r->selection.end.col;
+    if (0 < c1 && c1 < r->TermWin.ncol) {
 	r1 = r->selection.end.row + r->TermWin.saveLines;
-	c1 = r->selection.end.col;
 	if (IS_MULTI1(r->screen.rend[r1][c1 - 1])
 	    && IS_MULTI2(r->screen.rend[r1][c1]))
 	    r->selection.end.col++;
@@ -3515,11 +3515,12 @@ rxvt_selection_send(rxvt_t *r, const XSe
 {
     XSelectionEvent ev;
 #ifdef USE_XIM
-    Atom32          target_list[4];
+    long            target_list[4];
 #else
-    Atom32          target_list[3];
+    long            target_list[3];
 #endif
     Atom            target;
+    long            time;
     XTextProperty   ct;
     XICCEncodingStyle style;
     char           *cl[2], dummy[1];
@@ -3540,16 +3541,17 @@ rxvt_selection_send(rxvt_t *r, const XSe
 	target_list[3] = (Atom32) r->h->xa[XA_COMPOUND_TEXT];
 #endif
 	XChangeProperty(r->Xdisplay, rq->requestor, rq->property, XA_ATOM,
-			(8 * sizeof(target_list[0])), PropModeReplace,
+			32, PropModeReplace,
 			(unsigned char *)target_list,
 			(sizeof(target_list) / sizeof(target_list[0])));
 	ev.property = rq->property;
     } else if (rq->target == r->h->xa[XA_MULTIPLE]) {
 	/* TODO: Handle MULTIPLE */
     } else if (rq->target == r->h->xa[XA_TIMESTAMP] && r->selection.text) {
+	time = r->h->selection_time;
 	XChangeProperty(r->Xdisplay, rq->requestor, rq->property, XA_INTEGER,
-			(8 * sizeof(Time)), PropModeReplace,
-			(unsigned char *)&r->h->selection_time, 1);
+			32, PropModeReplace,
+			(unsigned char *)&time, 1);
 	ev.property = rq->property;
     } else if (rq->target == XA_STRING
 	       || rq->target == r->h->xa[XA_COMPOUND_TEXT]
