shithub: drawterm

Download patch

ref: 9d09c9315c3051e7633f7774ab65345804f1e192
parent: e8c4489e0da9e057997be3da11cef72ec039c9f8
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Jan 18 13:38:02 EST 2022

gui-wl: check clip content before strduping (fixes a crash)

--- a/gui-wl/wl-cb.c
+++ b/gui-wl/wl-cb.c
@@ -562,9 +562,7 @@
 	struct wl_data_source *source;
 
 	qlock(&wl->clip.lk);
-	if(wl->clip.content != nil)
-		free(wl->clip.content);
-
+	free(wl->clip.content);
 	wl->clip.content = strdup(s);
 	/* Do we still own the clipboard? */
 	if(wl->clip.posted == 1)
@@ -584,7 +582,7 @@
 {
 	char *s;
 	qlock(&wl->clip.lk);
-	s = strdup(wl->clip.content);
+	s = strdup(wl->clip.content != nil ? wl->clip.content : "");
 	qunlock(&wl->clip.lk);
 	return s;
 }