Kouhei Sutou
null+****@clear*****
Mon Jan 29 18:57:37 JST 2018
Kouhei Sutou 2018-01-29 18:57:37 +0900 (Mon, 29 Jan 2018) New Revision: b0e3ee9ce23a5693d6d7b57ef0467cc2f4fdc495 https://github.com/groonga/groonga/commit/b0e3ee9ce23a5693d6d7b57ef0467cc2f4fdc495 Message: hash: fix a memory leak for not tiny hash table GitHub: fix mroonga/mroonga#190 Reported by fuku1. Thanks!!! Modified files: lib/hash.c Modified: lib/hash.c (+23 -1) =================================================================== --- lib/hash.c 2018-01-29 17:28:28 +0900 (efe3fb4de) +++ lib/hash.c 2018-01-29 18:57:37 +0900 (c55adc17a) @@ -1,6 +1,6 @@ /* -*- c-basic-offset: 2 -*- */ /* - Copyright(C) 2009-2016 Brazil + Copyright(C) 2009-2018 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -331,6 +331,13 @@ grn_table_queue_lock_init(grn_ctx *ctx, grn_table_queue *queue) } static void +grn_table_queue_lock_fin(grn_ctx *ctx, grn_table_queue *queue) +{ + MUTEX_FIN(queue->mutex); + COND_FIN(queue->cond); +} + +static void grn_table_queue_init(grn_ctx *ctx, grn_table_queue *queue) { queue->head = 0; @@ -340,6 +347,12 @@ grn_table_queue_init(grn_ctx *ctx, grn_table_queue *queue) grn_table_queue_lock_init(ctx, queue); } +static void +grn_table_queue_fin(grn_ctx *ctx, grn_table_queue *queue) +{ + grn_table_queue_lock_fin(ctx, queue); +} + uint32_t grn_table_queue_size(grn_table_queue *queue) { @@ -2100,6 +2113,15 @@ grn_hash_close(grn_ctx *ctx, grn_hash *hash) if (grn_hash_is_io_hash(hash)) { rc = grn_io_close(ctx, hash->io); GRN_OBJ_FIN(ctx, &(hash->token_filters)); + { + grn_table_queue *queue; + if (GRN_HASH_IS_LARGE_KEY(hash)) { + queue = &(hash->header.large->queue); + } else { + queue = &(hash->header.normal->queue); + } + grn_table_queue_fin(ctx, queue); + } } else { GRN_ASSERT(ctx == hash->ctx); rc = grn_tiny_hash_fin(ctx, hash); -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180129/fb7c9271/attachment-0001.htm