neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libasn1c/+/37990?usp=email )
Change subject: coverity CID#57682 ......................................................................
coverity CID#57682
do not access ct->range_bits when ct == NULL.
Change-Id: I03b831e9e90591fd205e7d0e66314e1ce7061d24 --- M src/constr_CHOICE.c 1 file changed, 10 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libasn1c refs/changes/90/37990/1
diff --git a/src/constr_CHOICE.c b/src/constr_CHOICE.c index 05e1182..c7d7032 100644 --- a/src/constr_CHOICE.c +++ b/src/constr_CHOICE.c @@ -1077,6 +1077,7 @@ asn_per_constraint_t *ct; void *memb_ptr; int present; + asn_enc_rval_t rval;
if(!sptr) _ASN_ENCODE_FAILED;
@@ -1136,18 +1137,18 @@
return elm->type->aper_encoder(elm->type, elm->per_constraints, memb_ptr, po); - } else { - asn_enc_rval_t rval; - if(specs->ext_start == -1) - _ASN_ENCODE_FAILED; + } + + if(specs->ext_start == -1) + _ASN_ENCODE_FAILED; + if (ct) { if(aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start)) _ASN_ENCODE_FAILED; - if(aper_open_type_put(elm->type, elm->per_constraints, - memb_ptr, po)) - _ASN_ENCODE_FAILED; - rval.encoded = 0; - _ASN_ENCODED_OK(rval); } + if(aper_open_type_put(elm->type, elm->per_constraints, memb_ptr, po)) + _ASN_ENCODE_FAILED; + rval.encoded = 0; + _ASN_ENCODED_OK(rval); }
int