From 583101d34bdbe6c90e178c979fd4de2f9c4c2785 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 28 Jul 2020 16:05:08 +0200 Subject: server: Fix some memory leaks --- command.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/command.c b/command.c index 1cd8619..8fa343d 100644 --- a/command.c +++ b/command.c @@ -191,7 +191,7 @@ static struct cmd_retval cmd_invite(struct conn_data *data,const char *tag,const db_add_member(roomid,user2); - const char *inviter_username=db_get_username(data->userid); + char *inviter_username=db_get_username(data->userid); const char *username=args[1]; char *joinbuf=NULL; @@ -199,6 +199,8 @@ static struct cmd_retval cmd_invite(struct conn_data *data,const char *tag,const char *invitebuf=NULL; i64 invitebuflen=asprintf(&invitebuf,"_push invite %s %s\n",roomname,inviter_username); + free(inviter_username); + event_emit_join(make_timestamp(),username,roomname); struct db_user_list members=db_list_members(roomid); @@ -318,6 +320,7 @@ static struct cmd_retval history_cmd_helper( len=asprintf(&buf,"%s history_message %" PRIi64 " %s %s %" PRIi64 " %" PRIi64 " %s\n", tag,ml.count-1-i,roomname,username,ml.list[i].timestamp, ml.list[i].msgid,ml.list[i].message); + free(username); closed=net_send_raw_text(data->fd,buf,len); free(buf); if(closed)break; -- cgit v1.2.3-70-g09d2