From 412dbefe671eb365107e34bda0437efd0575ea40 Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Thu, 11 Jun 2015 03:57:44 +0300 Subject: [PATCH] fixed yet another very potential memleak; --- lib/channel.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/channel.c b/lib/channel.c index 665ed26..3f779b8 100644 --- a/lib/channel.c +++ b/lib/channel.c @@ -218,7 +218,7 @@ int channel_close(chnl_t *chnl) { char *uuid_; usrtc_node_t *node = NULL; - int r; + int r = 0; conn_t *co = chnl->connection; conn_sys_t *ssys = co->ssys; sxmsg_t *sms; @@ -244,9 +244,10 @@ int channel_close(chnl_t *chnl) uuid_ = __generate_uuid(); pl = malloc(sizeof(sxpayload_t)); - if(!pl) { + if(!pl || !uuid_) { pthread_rwlock_unlock(&(chnl->msglock)); - free(uuid_); + if(pl) free(pl); + if(uuid_) free(uuid_); return ENOMEM; } if(__create_sys_msg(&sms, uuid_, chnl, pl)) {