aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-09-17 16:15:29 +0200
committerBjörn Gustavsson <[email protected]>2013-09-30 10:11:10 +0200
commit04e6e90856420df28dbac918de3ec22524a221cb (patch)
tree972eefdb1fa66cb2adb13d9a3bfe06effa085b36 /lib
parent0f430abcb189988a7faf55386557b2b74afa6f56 (diff)
downloadotp-04e6e90856420df28dbac918de3ec22524a221cb.tar.gz
otp-04e6e90856420df28dbac918de3ec22524a221cb.tar.bz2
otp-04e6e90856420df28dbac918de3ec22524a221cb.zip
asn1ct_value: Handle named INTEGERs with constraints
The asn1ct:value/2 function would crash for name INTEGERs with constraints, such as INTEGER {a(2),b(3),z(17)} (2|3|17, ...).
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/src/asn1ct_value.erl17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/asn1/src/asn1ct_value.erl b/lib/asn1/src/asn1ct_value.erl
index 992210232f..862b3c4ea5 100644
--- a/lib/asn1/src/asn1ct_value.erl
+++ b/lib/asn1/src/asn1ct_value.erl
@@ -167,17 +167,16 @@ from_type_prim(M, D) ->
case D#type.def of
'INTEGER' ->
i_random(C);
- {'INTEGER',NamedNumberList} ->
- NN = [X||{X,_} <- NamedNumberList],
- case NN of
+ {'INTEGER',[_|_]=NNL} ->
+ case C of
[] ->
- i_random(C);
+ {N,_} = lists:nth(random(length(NNL)), NNL),
+ N;
_ ->
- case C of
- [] ->
- lists:nth(random(length(NN)),NN);
- _ ->
- lists:nth((fun(0)->1;(X)->X end(i_random(C))),NN)
+ V = i_random(C),
+ case lists:keyfind(V, 2, NNL) of
+ false -> V;
+ {N,V} -> N
end
end;
Enum when is_tuple(Enum),element(1,Enum)=='ENUMERATED' ->