hnbap: Free ASN.1 components after they are no longer needed
diff --git a/src/hnbap_common.c b/src/hnbap_common.c
index 0bb08fe..d72ca3e 100644
--- a/src/hnbap_common.c
+++ b/src/hnbap_common.c
@@ -141,7 +141,7 @@
Criticality_t criticality,
asn_TYPE_descriptor_t * td, void *sptr)
{
-
+ struct msgb *msg;
HNBAP_PDU_t pdu;
int rc;
@@ -156,7 +156,10 @@
return NULL;
}
- return _hnbap_gen_msg(&pdu);
+ msg = _hnbap_gen_msg(&pdu);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu);
+
+ return msg;
}
struct msgb *hnbap_generate_successful_outcome(
@@ -165,7 +168,7 @@
asn_TYPE_descriptor_t * td,
void *sptr)
{
-
+ struct msgb *msg;
HNBAP_PDU_t pdu;
int rc;
@@ -180,7 +183,10 @@
return NULL;
}
- return _hnbap_gen_msg(&pdu);
+ msg = _hnbap_gen_msg(&pdu);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu);
+
+ return msg;
}
struct msgb *hnbap_generate_unsuccessful_outcome(
@@ -189,7 +195,7 @@
asn_TYPE_descriptor_t * td,
void *sptr)
{
-
+ struct msgb *msg;
HNBAP_PDU_t pdu;
int rc;
@@ -204,7 +210,10 @@
return NULL;
}
- return _hnbap_gen_msg(&pdu);
+ msg = _hnbap_gen_msg(&pdu);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, &pdu);
+
+ return msg;
}
IE_t *hnbap_new_ie(ProtocolIE_ID_t id,
@@ -214,7 +223,7 @@
IE_t *buff;
- if ((buff = malloc(sizeof(IE_t))) == NULL) {
+ if ((buff = MALLOC(sizeof(IE_t))) == NULL) {
// Possible error on malloc
return NULL;
}
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index 9378c7a..219169a 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -69,6 +69,8 @@
&asn_DEF_HNBRegisterAccept,
&accept_out);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBRegisterAccept, &accept_out);
+
return hnbgw_hnbap_tx(ctx, msg);
}
@@ -294,6 +296,8 @@
rc = _hnbgw_hnbap_rx(hnb, pdu);
+ ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_HNBAP_PDU, pdu);
+
return rc;
}