From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 A9343469710 for ; Thu, 28 May 2020 02:25:44 +0300 (MSK) From: Vladislav Shpilevoy Date: Thu, 28 May 2020 01:25:41 +0200 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/1] fk: fix wrong sizeof() in fk_constraint_def_sizeof() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, korablev@tarantool.org The function returns a number of bytes needed to store an fk_constraint_def object with its name and links. However it used sizeof(struct fk_constraint) instead of sizeof(struct fk_constraint_def) to calculate base object size. This worked only because fk_constraint is bigger than fk_constraint_def. --- Branch: http://github.com/tarantool/tarantool/tree/gerold103/fk_constraint_sizeof src/box/fk_constraint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/box/fk_constraint.h b/src/box/fk_constraint.h index fee82afb0..b1e0cfb84 100644 --- a/src/box/fk_constraint.h +++ b/src/box/fk_constraint.h @@ -131,7 +131,7 @@ struct fk_constraint { static inline size_t fk_constraint_def_sizeof(uint32_t link_count, uint32_t name_len) { - return sizeof(struct fk_constraint) + + return sizeof(struct fk_constraint_def) + link_count * sizeof(struct field_link) + name_len + 1; } -- 2.21.1 (Apple Git-122.3)