Fix Coverity Scan 1486961 Resource leak

pull/2505/head
Roger A. Light 4 years ago
parent a331057127
commit 016e03c285

@ -220,7 +220,7 @@ void context__disconnect(struct mosquitto *context)
if(context->transport == mosq_t_ws){
uint8_t buf[4] = {0x88, 0x02, 0x03, context->wsd.disconnect_reason};
/* Send the disconnect reason, but don't care if it fails */
if(send(context->sock, buf, 4, 0));
if(send(context->sock, buf, 4, 0)){};
}
#endif
plugin__handle_disconnect(context, -1);

@ -297,13 +297,15 @@ static int sub__add_normal(struct mosquitto *context, const char *sub, uint8_t q
csub->hier = subhier;
csub->shared = NULL;
bool assigned = false;
for(i=0; i<context->sub_count; i++){
if(!context->subs[i]){
context->subs[i] = csub;
assigned = true;
break;
}
}
if(i == context->sub_count){
if(assigned == false){
subs = mosquitto__realloc(context->subs, sizeof(struct mosquitto__client_sub *)*(size_t)(context->sub_count + 1));
if(!subs){
DL_DELETE(subhier->subs, newleaf);

Loading…
Cancel
Save