diff --git a/src/box/tuple.cc b/src/box/tuple.cc index ce85c7850df3c1c89cfaf8a9588089226ca49dda..793ec47863234984c7c6e881b991af7b1ce51236 100644 --- a/src/box/tuple.cc +++ b/src/box/tuple.cc @@ -380,7 +380,10 @@ tuple_new(struct tuple_format *format, uint32_t field_count, { size_t tuple_len = end - *data; - if (tuple_len != tuple_range_size(data, end, field_count)) + uint32_t test_field_count = field_count; + if (tuple_len != tuple_range_size(data, end, &test_field_count)) + tnt_raise(IllegalParams, "tuple_new(): incorrect tuple format"); + if (test_field_count > 0) tnt_raise(IllegalParams, "tuple_new(): incorrect tuple format"); struct tuple *new_tuple = tuple_alloc(format, tuple_len); diff --git a/src/box/tuple.h b/src/box/tuple.h index f317bfcc666fc0fc5b6cc7922204826556148561..591f5dcb8e6ff04f4a591606726efc888fe32006 100644 --- a/src/box/tuple.h +++ b/src/box/tuple.h @@ -307,10 +307,10 @@ static inline size_t tuple_len(struct tuple *tuple) } static inline size_t -tuple_range_size(const char **begin, const char *end, uint32_t count) +tuple_range_size(const char **begin, const char *end, uint32_t *count) { const char *start = *begin; - while (*begin < end && count-- > 0) { + while (*begin < end && (*count)-- > 0) { size_t len = load_varint32(begin); *begin += len; }