From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 055F846970E for ; Mon, 3 Feb 2020 17:37:08 +0300 (MSK) Date: Mon, 3 Feb 2020 17:37:08 +0300 From: Sergey Ostanevich Message-ID: <20200203143708.GF547@tarantool.org> References: <20200128192249.10023-1-gorcunov@gmail.com> <20200128192249.10023-2-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200128192249.10023-2-gorcunov@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v7 1/5] box/request: add missing OutOfMemory diag_set List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tml Thanks! LGTM. Sergos On 28 Jan 22:22, Cyrill Gorcunov wrote: > In request_create_from_tuple and request_handle_sequence > we may be unable to request memory for tuples, don't > forget to setup diag error otherwise diag_raise will > lead to nil dereference. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/request.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/src/box/request.c b/src/box/request.c > index 82232a155..994f2da62 100644 > --- a/src/box/request.c > +++ b/src/box/request.c > @@ -109,8 +109,10 @@ request_create_from_tuple(struct request *request, struct space *space, > * the tuple data to WAL on commit. > */ > char *buf = region_alloc(&fiber()->gc, size); > - if (buf == NULL) > + if (buf == NULL) { > + diag_set(OutOfMemory, size, "region_alloc", "tuple"); > return -1; > + } > memcpy(buf, data, size); > request->tuple = buf; > request->tuple_end = buf + size; > @@ -199,8 +201,10 @@ request_handle_sequence(struct request *request, struct space *space) > size_t buf_size = (request->tuple_end - request->tuple) + > mp_sizeof_uint(UINT64_MAX); > char *tuple = region_alloc(&fiber()->gc, buf_size); > - if (tuple == NULL) > + if (tuple == NULL) { > + diag_set(OutOfMemory, buf_size, "region_alloc", "tuple"); > return -1; > + } > char *tuple_end = mp_encode_array(tuple, len); > > if (unlikely(key != data)) { > -- > 2.20.1 >