From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 B33FC46970E for ; Mon, 27 Jan 2020 01:30:37 +0300 (MSK) Received: by mail-lj1-f195.google.com with SMTP id q8so4608674ljb.2 for ; Sun, 26 Jan 2020 14:30:37 -0800 (PST) From: Cyrill Gorcunov Date: Mon, 27 Jan 2020 01:30:21 +0300 Message-Id: <20200126223023.10197-2-gorcunov@gmail.com> In-Reply-To: <20200126223023.10197-1-gorcunov@gmail.com> References: <20200126223023.10197-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/3] box/request: add missing OutOfMemory diag_set List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml 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