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 CB3624696C6 for ; Tue, 7 Apr 2020 18:15:50 +0300 (MSK) Received: by mail-lj1-f195.google.com with SMTP id r24so4159945ljd.4 for ; Tue, 07 Apr 2020 08:15:50 -0700 (PDT) From: Cyrill Gorcunov Date: Tue, 7 Apr 2020 18:14:56 +0300 Message-Id: <20200407151500.3410-4-gorcunov@gmail.com> In-Reply-To: <20200407151500.3410-1-gorcunov@gmail.com> References: <20200407151500.3410-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v12 3/8] request: add missing OutOfMemory diag_set List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kirill Yukhin Cc: 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