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)) {