~foura/wired

783a075cd2cec169631759a815deaf3717edb925 — james palmer 1 year, 2 months ago 5218230
fix segfault if the input box was empty
1 files changed, 7 insertions(+), 4 deletions(-)

M main.c
M main.c => main.c +7 -4
@@ 80,6 80,11 @@ readbody(AWin *w)
	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 @@ readbody(AWin *w)
			break;
	}
	
	awinclear(w);
	
	return buf;
}



@@ 97,7 100,7 @@ domessage(Session *s, char *msg)
{
	char *buf;
	
	if(msg[0] == '\0')
	if(!msg)
		return;
	
	buf = smprint("%s • %s\n", s->usr, msg);


@@ 112,7 115,7 @@ doaction(Session *s, char *msg)
{
	char *buf;
	
	if(msg[0] == '\0')
	if(!msg)
		return;
	
	buf = smprint("* %s %s\n", s->usr, msg);