per encoding support

diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c
index a0a6d76..b8d6fa9 100644
--- a/skeletons/constr_CHOICE.c
+++ b/skeletons/constr_CHOICE.c
@@ -852,22 +852,22 @@
 
 	if(ct && ct->flags & APC_EXTENSIBLE) {
 		value = per_get_few_bits(pd, 1);
-		if(value < 0) _ASN_DECODE_FAILED;
+		if(value < 0) _ASN_DECODE_STARVED;
 		if(value) ct = 0;	/* Not restricted */
 	}
 
 	if(ct && ct->range_bits >= 0) {
 		value = per_get_few_bits(pd, ct->range_bits);
-		if(value < 0) _ASN_DECODE_FAILED;
-		if(value > ct->upper_bound)
-			_ASN_DECODE_FAILED;
+		if(value < 0) _ASN_DECODE_STARVED;
 		ASN_DEBUG("CHOICE %s got index %d in range %d",
 			td->name, value, ct->range_bits);
+		if(value > ct->upper_bound)
+			_ASN_DECODE_FAILED;
 	} else {
 		if(specs->ext_start == -1)
 			_ASN_DECODE_FAILED;
 		value = uper_get_nsnnwn(pd);
-		if(value < 0) _ASN_DECODE_FAILED;
+		if(value < 0) _ASN_DECODE_STARVED;
 		value += specs->ext_start;
 		if(value >= td->elements_count)
 			_ASN_DECODE_FAILED;