[Groonga-commit] groonga/groonga at 67d5265 [master] ctx: release resources if grn_ctx_impl_init fails to initialize expr_vars

Back to archive index

Susumu Yata null+****@clear*****
Mon Nov 20 16:10:46 JST 2017


Susumu Yata	2017-11-20 16:10:46 +0900 (Mon, 20 Nov 2017)

  New Revision: 67d526599c5dca3ed58574842ae3ce134d90766d
  https://github.com/groonga/groonga/commit/67d526599c5dca3ed58574842ae3ce134d90766d

  Message:
    ctx: release resources if grn_ctx_impl_init fails to initialize expr_vars

  Modified files:
    lib/ctx.c

  Modified: lib/ctx.c (+10 -1)
===================================================================
--- lib/ctx.c    2017-11-20 14:08:37 +0900 (a7385a162)
+++ lib/ctx.c    2017-11-20 16:10:46 +0900 (a43dd41cd)
@@ -240,7 +240,16 @@ grn_ctx_impl_init(grn_ctx *ctx)
   }
   ctx->impl->db = NULL;
 
-  ctx->impl->expr_vars = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(grn_obj *), 0);
+  if (!(ctx->impl->expr_vars = grn_hash_create(ctx, NULL, sizeof(grn_id),
+                                               sizeof(grn_obj *), 0))) {
+    grn_array_close(ctx, ctx->impl->values);
+    grn_pat_close(ctx, ctx->impl->temporary_columns);
+    CRITICAL_SECTION_FIN(ctx->impl->lock);
+    grn_io_anon_unmap(ctx, &mi, IMPL_SIZE);
+    grn_hash_close(ctx, ctx->impl->ios);
+    ctx->impl = NULL;
+    return ctx->rc;
+  }
   ctx->impl->stack_curr = 0;
   ctx->impl->curr_expr = NULL;
   GRN_TEXT_INIT(&ctx->impl->current_request_id, 0);
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171120/9e03072e/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index