shithub: wired

Download patch

ref: 783a075cd2cec169631759a815deaf3717edb925
parent: 52182308b97675ca766afdb64c1f2aeb3e8334a9
author: james palmer <[email protected]>
date: Mon Jun 7 18:47:10 EDT 2021

fix segfault if the input box was empty

--- a/main.c
+++ b/main.c
@@ -80,6 +80,11 @@
 	buf = Brdstr(fd, '\0', 0);
 	Bterm(fd);
 	
+	awinclear(w);
+	
+	if(!buf)
+		return nil;
+	
 	for(i = strlen(buf)-1; i > 0; i--) {
 		if(buf[i] == '' || buf[i] == '\n')
 			buf[i] = '\0';
@@ -87,8 +92,6 @@
 			break;
 	}
 	
-	awinclear(w);
-	
 	return buf;
 }
 
@@ -97,7 +100,7 @@
 {
 	char *buf;
 	
-	if(msg[0] == '\0')
+	if(!msg)
 		return;
 	
 	buf = smprint("%s • %s\n", s->usr, msg);
@@ -112,7 +115,7 @@
 {
 	char *buf;
 	
-	if(msg[0] == '\0')
+	if(!msg)
 		return;
 	
 	buf = smprint("* %s %s\n", s->usr, msg);