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 77FBB4696C6 for ; Sat, 4 Apr 2020 19:16:04 +0300 (MSK) Received: by mail-lj1-f195.google.com with SMTP id k21so10178104ljh.2 for ; Sat, 04 Apr 2020 09:16:04 -0700 (PDT) From: Cyrill Gorcunov Date: Sat, 4 Apr 2020 19:15:19 +0300 Message-Id: <20200404161524.7466-4-gorcunov@gmail.com> In-Reply-To: <20200404161524.7466-1-gorcunov@gmail.com> References: <20200404161524.7466-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v11 3/8] 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. Acked-by: Sergey Ostanevich Acked-by: Konstantin Osipov 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