From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E9FB629AF5 for ; Thu, 14 Mar 2019 15:36:41 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5TDuXxXdG1NV for ; Thu, 14 Mar 2019 15:36:41 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 06B58297BF for ; Thu, 14 Mar 2019 15:36:40 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH v4 2/8] sql: set SQL parser errors via diag_set() From: "n.pettik" In-Reply-To: <21543710-C2CB-4818-AE87-FA1BE3AEB0A4@tarantool.org> Date: Thu, 14 Mar 2019 22:36:38 +0300 Content-Transfer-Encoding: 7bit Message-Id: <4F52C20E-0EDB-4411-B3FE-BBE7C6FB047D@tarantool.org> References: <3be89ad14633e9b03c01200ee3d1b3c6776fccc5.1552494059.git.imeevma@gmail.com> <21543710-C2CB-4818-AE87-FA1BE3AEB0A4@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen Almost forgot. Apply this small diff please. You confused malloc with realloc in diag_set(). And it improves readability of code. diff --git a/src/box/sql/malloc.c b/src/box/sql/malloc.c index 8812298e0..83ab23589 100644 --- a/src/box/sql/malloc.c +++ b/src/box/sql/malloc.c @@ -51,12 +51,12 @@ sql_sized_malloc(int nByte) assert(nByte > 0); nByte = ROUND8(nByte); p = malloc(nByte + 8); - if (p) { - p[0] = nByte; - p++; - } else { - diag_set(OutOfMemory, nByte, "realloc", "p"); + if (p == NULL) { + diag_set(OutOfMemory, nByte, "malloc", "p"); + return NULL; } + p[0] = nByte; + p++; return (void *)p; } @@ -109,12 +109,12 @@ sql_sized_realloc(void *pPrior, int nByte) assert(nByte == ROUND8(nByte)); /* EV: R-46199-30249 */ p--; p = realloc(p, nByte + 8); - if (p) { - p[0] = nByte; - p++; - } else { - diag_set(OutOfMemory, nByte, "malloc", "p"); + if (p == NULL) { + diag_set(OutOfMemory, nByte, "realloc", "p"); + return NULL; } + p[0] = nByte; + p++; return (void *)p; }