{hnbap,rua,ranap}_common: check for encoding errors in new_ie()
diff --git a/src/hnbap_common.c b/src/hnbap_common.c
index 2cd7ee2..1c92542 100644
--- a/src/hnbap_common.c
+++ b/src/hnbap_common.c
@@ -222,6 +222,7 @@
 {
 
 	IE_t *buff;
+	int rc;
 
 	if ((buff = CALLOC(1, sizeof(IE_t))) == NULL) {
 		// Possible error on malloc
@@ -231,7 +232,12 @@
 	buff->id = id;
 	buff->criticality = criticality;
 
-	ANY_fromType_aper(&buff->value, type, sptr);
+	rc = ANY_fromType_aper(&buff->value, type, sptr);
+	if (rc < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+		FREEMEM(buff);
+		return NULL;
+	}
 
 	if (asn1_xer_print)
 		if (xer_fprint(stdout, &asn_DEF_IE, buff) < 0) {
diff --git a/src/ranap_common.c b/src/ranap_common.c
index 8081c01..c12941c 100644
--- a/src/ranap_common.c
+++ b/src/ranap_common.c
@@ -164,8 +164,8 @@
 			 RANAP_Criticality_t criticality,
 			 asn_TYPE_descriptor_t * type, void *sptr)
 {
-
 	RANAP_IE_t *buff;
+	int rc;
 
 	if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
 		// Possible error on malloc
@@ -175,7 +175,12 @@
 	buff->id = id;
 	buff->criticality = criticality;
 
-	ANY_fromType_aper(&buff->value, type, sptr);
+	rc = ANY_fromType_aper(&buff->value, type, sptr);
+	if (rc < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+		FREEMEM(buff);
+		return NULL;
+	}
 
 	if (asn1_xer_print)
 		if (xer_fprint(stdout, &asn_DEF_RANAP_IE, buff) < 0) {
@@ -192,8 +197,8 @@
 				RANAP_Criticality_t criticality2,
 				asn_TYPE_descriptor_t *type2, void *sptr2)
 {
-
 	RANAP_ProtocolIE_FieldPair_t *buff;
+	int rc;
 
 	if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
 		// Possible error on malloc
@@ -204,8 +209,19 @@
 	buff->firstCriticality = criticality1;
 	buff->secondCriticality = criticality2;
 
-	ANY_fromType_aper(&buff->firstValue, type1, sptr1);
-	ANY_fromType_aper(&buff->secondValue, type2, sptr2);
+	rc = ANY_fromType_aper(&buff->firstValue, type1, sptr1);
+	if (rc < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+		FREEMEM(buff);
+		return NULL;
+	}
+
+	rc = ANY_fromType_aper(&buff->secondValue, type2, sptr2);
+	if (rc < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+		FREEMEM(buff);
+		return NULL;
+	}
 
 	if (asn1_xer_print)
 		if (xer_fprint(stdout, &asn_DEF_RANAP_ProtocolIE_FieldPair, buff) < 0) {
diff --git a/src/rua_common.c b/src/rua_common.c
index 3d7bacd..5809b7f 100644
--- a/src/rua_common.c
+++ b/src/rua_common.c
@@ -196,6 +196,7 @@
 {
 
 	RUA_IE_t *buff;
+	int rc;
 
 	if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
 		// Possible error on malloc
@@ -205,7 +206,12 @@
 	buff->id = id;
 	buff->criticality = criticality;
 
-	ANY_fromType_aper(&buff->value, type, sptr);
+	rc = ANY_fromType_aper(&buff->value, type, sptr);
+	if (rc < 0) {
+		LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+		FREEMEM(buff);
+		return NULL;
+	}
 
 	if (asn1_xer_print)
 		if (xer_fprint(stdout, &asn_DEF_RUA_IE, buff) < 0) {