Kouhei Sutou 2018-10-30 15:26:08 +0900 (Tue, 30 Oct 2018) Revision: 5e24be2a9a914e6df219d84f2a2c7c8346d7ecb8 https://github.com/groonga/groonga/commit/5e24be2a9a914e6df219d84f2a2c7c8346d7ecb8 Message: Fix a memory leak Modified files: lib/table.c Modified: lib/table.c (+9 -5) =================================================================== --- lib/table.c 2018-10-30 15:23:19 +0900 (2c31c5215) +++ lib/table.c 2018-10-30 15:26:08 +0900 (317244218) @@ -480,7 +480,7 @@ grn_table_get_modules_string(grn_ctx *ctx, const char *module_name, const char *context_tag) { - grn_obj *procs; + grn_obj procs; unsigned int i, n; GRN_API_ENTER; @@ -493,19 +493,21 @@ grn_table_get_modules_string(grn_ctx *ctx, GRN_API_RETURN(ctx->rc); } - procs = grn_obj_get_info(ctx, table, type, NULL); - if (!procs) { + GRN_PTR_INIT(&procs, GRN_OBJ_VECTOR, GRN_ID_NIL); + grn_obj_get_info(ctx, table, type, &procs); + if (GRN_BULK_VSIZE(&procs) == 0) { + GRN_OBJ_FIN(ctx, &procs); GRN_API_RETURN(ctx->rc); } - n = grn_vector_size(ctx, procs); + n = grn_vector_size(ctx, &procs); if (n == 0) { GRN_API_RETURN(ctx->rc); } for (i = 0; i < n; i++) { char real_module_name[GRN_TABLE_MAX_KEY_SIZE]; - grn_obj *proc = GRN_PTR_VALUE_AT(procs, i); + grn_obj *proc = GRN_PTR_VALUE_AT(&procs, i); if (i > 0) { GRN_TEXT_PUTS(ctx, output, ", "); @@ -523,6 +525,8 @@ grn_table_get_modules_string(grn_ctx *ctx, real_module_name); } + GRN_OBJ_FIN(ctx, &procs); + GRN_API_RETURN(ctx->rc); } -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20181030/d75e4548/attachment-0001.html>