From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 DE443469719 for ; Thu, 24 Sep 2020 16:45:44 +0300 (MSK) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) From: Roman Khabibov In-Reply-To: <20200924131205.GA27508@tarantool.org> Date: Thu, 24 Sep 2020 16:45:42 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200923142647.77892-1-roman.habibov@tarantool.org> <20200924131205.GA27508@tarantool.org> 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: Nikita Pettik Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy Hello, thanks for the review! > On Sep 24, 2020, at 16:12, Nikita Pettik = wrote: >=20 > On 23 Sep 17:26, Roman Khabibov wrote: >> Fix a memory leak generated by allocation of indexes array of >> parser ephemeral space. >> --- >=20 > I'd fix a bit commit message: >=20 > Fix a memory leak during execution of CREATE TABLE statement: > indexes to be created are stored in space->index array, which in > turn is allocated using malloc, but is never freed. >=20 > LGTM otherwise. >=20 >> Branch: = https://github.com/tarantool/tarantool/tree/romanhabibov/sql-memleak >>=20 >> P.S. It's really memleak, I checked with valgrind. >>=20 >> src/box/sql/tokenize.c | 2 ++ >> 1 file changed, 2 insertions(+) >>=20 >> 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 =3D 0; i < space->index_count; ++i) >> index_def_delete(space->index[i]->def); >> + if (space->index_count !=3D 0) >> + free(space->index); >> } >>=20 >> /** >> --=20 >> 2.24.3 (Apple Git-128) >>=20 Done. commit b7de62663cde2a2b9d2181a9628602a560b268e1 Author: Roman Khabibov Date: Wed Sep 23 14:40:23 2020 +0300 sql: fix memleak during parsing =20 Fix a memory leak during execution of CREATE TABLE statement: indexes to be created are stored in space->index array, which in turn is allocated using malloc, but is never freed. 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 =3D 0; i < space->index_count; ++i) index_def_delete(space->index[i]->def); + if (space->index_count !=3D 0) + free(space->index); } =20 /**