summaryrefslogtreecommitdiff
path: root/lib/erl/src
diff options
context:
space:
mode:
authorDavid Reiss <dreiss@apache.org>2010-08-30 22:05:58 +0000
committerDavid Reiss <dreiss@apache.org>2010-08-30 22:05:58 +0000
commitb4ab00847635ef74a8c03f6336e8378b5979c3e7 (patch)
treeaa4859fd2f8a897676604eb8a13192a923ec92f1 /lib/erl/src
parent5ed313d998c3a5dc43c4bc9a22d2db57162bd28e (diff)
downloadthrift-b4ab00847635ef74a8c03f6336e8378b5979c3e7.tar.gz
erlang: Verify elt/key/val when reading list/set/map
For now, exit on a badmatch if one is wrong. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991000 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'lib/erl/src')
-rw-r--r--lib/erl/src/thrift_protocol.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/erl/src/thrift_protocol.erl b/lib/erl/src/thrift_protocol.erl
index db7d22361..bb499ce7b 100644
--- a/lib/erl/src/thrift_protocol.erl
+++ b/lib/erl/src/thrift_protocol.erl
@@ -135,6 +135,7 @@ read(IProto, S={struct, Structure}) when is_list(Structure) ->
read(IProto0, {list, Type}) ->
{IProto1, #protocol_list_begin{etype = EType, size = Size}} =
read(IProto0, list_begin),
+ {EType, EType} = {term_to_typeid(Type), EType},
{List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) ->
{ProtoS1, {ok, Item}} = read(ProtoS0, Type),
{Item, ProtoS1}
@@ -145,8 +146,10 @@ read(IProto0, {list, Type}) ->
{IProto3, {ok, List}};
read(IProto0, {map, KeyType, ValType}) ->
- {IProto1, #protocol_map_begin{size = Size}} =
+ {IProto1, #protocol_map_begin{size = Size, ktype = KType, vtype = VType}} =
read(IProto0, map_begin),
+ {KType, KType} = {term_to_typeid(KeyType), KType},
+ {VType, VType} = {term_to_typeid(ValType), VType},
{List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) ->
{ProtoS1, {ok, Key}} = read(ProtoS0, KeyType),
{ProtoS2, {ok, Val}} = read(ProtoS1, ValType),
@@ -160,6 +163,7 @@ read(IProto0, {map, KeyType, ValType}) ->
read(IProto0, {set, Type}) ->
{IProto1, #protocol_set_begin{etype = EType, size = Size}} =
read(IProto0, set_begin),
+ {EType, EType} = {term_to_typeid(Type), EType},
{List, IProto2} = lists:mapfoldl(fun(_, ProtoS0) ->
{ProtoS1, {ok, Item}} = read(ProtoS0, Type),
{Item, ProtoS1}