pthread_t tid;
pthread_attr_init(&cb_attr);
pthread_attr_setdetachstate(&cb_attr,PTHREAD_CREATE_DETACHED);
- return pthread_create(&tid, &cb_attr,&monitor_loglevel_change_handler,(void *)strdup(fileName));
+ return pthread_create(&tid, &cb_attr,&monitor_loglevel_change_handler,(void *)fileName);
}
#if !(defined(UNIT_TEST) || defined(MODULE_TEST))
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
/* We have processed all incoming connections. */
+ if(peerInfo)
+ free(peerInfo);
break;
} else {
+ if(peerInfo)
+ free(peerInfo);
mdclog_write(MDCLOG_ERR, "Accept error, errno = %s", strerror(errno));
break;
}
if (setSocketNoBlocking(peerInfo->fileDescriptor) == -1) {
mdclog_write(MDCLOG_ERR, "setSocketNoBlocking failed to set new connection %s on port %s\n", hostBuff, portBuff);
close(peerInfo->fileDescriptor);
+ if(peerInfo)
+ free(peerInfo);
break;
#endif
}
if (ans < 0) {
mdclog_write(MDCLOG_ERR, "Failed to get info on connection request. %s\n", strerror(errno));
close(peerInfo->fileDescriptor);
+ if(peerInfo)
+ free(peerInfo);
break;
}
if (mdclog_level_get() >= MDCLOG_DEBUG) {
(EPOLLIN | EPOLLET),
params->sctpMap, nullptr,
0) != 0) {
+ if(peerInfo)
+ free(peerInfo);
break;
}
break;
if (rval.code != RC_OK) {
mdclog_write(MDCLOG_ERR, "Error %d Decoding (unpack) E2AP PDU from RAN : %s", rval.code,
message.peerInfo->enodbName);
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
break;
}
message.peerInfo->enodbName, end.tv_sec - decodeStart.tv_sec, end.tv_nsec - decodeStart.tv_nsec);
}
numOfMessages++;
+#ifndef UNIT_TEST
if (pdu != nullptr) {
- ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu);
- //ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
- //pdu = nullptr;
+ // ASN_STRUCT_RESET(asn_DEF_E2AP_PDU, pdu); /* With reset we were not freeing the memory and was causing the leak here. */
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
}
-#ifdef UNIT_TEST
+#else
done = 1;
break;
#endif
mdclog_write(MDCLOG_ERR, "Error %d Decoding (unpack) setup response from E2MGR : %s",
rval.code,
message.message.enodbName);
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
}
rmrMessageBuffer.sendMessage->payload, buff_size);
if (er.encoded == -1) {
mdclog_write(MDCLOG_ERR, "encoding of %s failed, %s", asn_DEF_E2AP_PDU.name, strerror(errno));
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
} else if (er.encoded > (ssize_t)buff_size) {
mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s, at %s line %d",
asn_DEF_E2AP_PDU.name,
__func__,
__LINE__);
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
}
rmrMessageBuffer.sendMessage->len = er.encoded;
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return 0;
}
mdclog_write(MDCLOG_ERR, "Error %d Decoding (unpack) setup response from E2MGR : %s",
rval.code,
message.message.enodbName);
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
}
}
if (er.encoded == -1) {
mdclog_write(MDCLOG_ERR, "encoding of %s failed, %s", asn_DEF_E2AP_PDU.name, strerror(errno));
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
} else if (er.encoded > (ssize_t)buff_size) {
mdclog_write(MDCLOG_ERR, "Buffer of size %d is to small for %s, at %s line %d",
asn_DEF_E2AP_PDU.name,
__func__,
__LINE__);
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return -1;
}
rmrMessageBuffer.rcvMessage->len = er.encoded;
+ if (pdu != nullptr) {
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, pdu);
+ pdu = nullptr;
+ }
return 0;
}