From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 96407469719 for ; Sat, 15 Feb 2020 20:33:41 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id z18so8958599lfe.2 for ; Sat, 15 Feb 2020 09:33:41 -0800 (PST) Date: Sat, 15 Feb 2020 20:33:39 +0300 From: Konstantin Osipov Message-ID: <20200215173339.GA19902@atlas> References: <20200214140339.4085-1-gorcunov@gmail.com> <20200214140339.4085-2-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200214140339.4085-2-gorcunov@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v10 1/4] 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 * Cyrill Gorcunov [20/02/14 17:06]: > 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. > > Acked-by: Sergey Ostanevich > Signed-off-by: Cyrill Gorcunov > --- > src/box/request.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > lgmt > 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 -- Konstantin Osipov, Moscow, Russia