aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-07-28 16:05:08 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-07-28 16:07:03 +0200
commit583101d34bdbe6c90e178c979fd4de2f9c4c2785 (patch)
tree65508c2af724a9212e41415ef6a09ad6f6871cc9
parentf70ab0a787c42467beed3e29720508dbfd2d7447 (diff)
server: Fix some memory leaks
-rw-r--r--command.c5
1 files changed, 4 insertions, 1 deletions
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;