From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 73001469719 for ; Fri, 25 Sep 2020 00:30:35 +0300 (MSK) References: <20200923142647.77892-1-roman.habibov@tarantool.org> From: Vladislav Shpilevoy Message-ID: <7c7ec873-3853-6f1e-9b47-7d1c161856a6@tarantool.org> Date: Thu, 24 Sep 2020 23:30:33 +0200 MIME-Version: 1.0 In-Reply-To: <20200923142647.77892-1-roman.habibov@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH] sql: fix memleak during parsing List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Roman Khabibov , tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! > diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c > index 5404a78e9..6cf92b4f7 100644 > --- a/src/box/sql/tokenize.c > +++ b/src/box/sql/tokenize.c > @@ -447,6 +447,8 @@ parser_space_delete(struct sql *db, struct space *space) > assert(space->def->opts.is_ephemeral); > for (uint32_t i = 0; i < space->index_count; ++i) > index_def_delete(space->index[i]->def); > + if (space->index_count != 0) > + free(space->index); Why do you check for index_count != 0? free() works fine on NULL, which is the case when index_count is 0.