fixed leaks in CHOICE/XER and REAL conversion
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 82ef966..1247f09 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -694,6 +694,7 @@
if(!st->buf || st->size < 2) {
ptr = (uint8_t *)MALLOC(2);
if(!ptr) return -1;
+ if(st->buf) FREEMEM(st->buf);
st->buf = ptr;
}
/* fpclassify(3) is not portable yet */
@@ -717,6 +718,7 @@
} else {
/* Negative zero. #8.5.3, 8.5.9 */
st->buf[0] = 0x43;
+ st->buf[1] = 0;
st->size = 1;
}
}
diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index 4ecb220..f3a53d3 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -605,6 +605,7 @@
asn_dec_rval_t tmprval;
void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */
+ unsigned old_present;
elm = &td->elements[edx];
@@ -624,13 +625,14 @@
XER_ADVANCE(tmprval.consumed);
ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d",
elm->type->name, tmprval.code);
- if(tmprval.code != RC_OK)
- RETURN(tmprval.code);
- assert(_fetch_present_idx(st,
- specs->pres_offset, specs->pres_size) == 0);
+ old_present = _fetch_present_idx(st,
+ specs->pres_offset, specs->pres_size);
+ assert(old_present == 0 || old_present == edx + 1);
/* Record what we've got */
_set_present_idx(st,
specs->pres_offset, specs->pres_size, edx + 1);
+ if(tmprval.code != RC_OK)
+ RETURN(tmprval.code);
ctx->phase = 3;
/* Fall through */
}