[Groonga-commit] groonga/groonga at 61ea014 [master] mrb: fix a memory leak of Column#[]

Back to archive index

Kouhei Sutou null+****@clear*****
Tue May 22 14:28:41 JST 2018


Kouhei Sutou	2018-05-22 14:28:41 +0900 (Tue, 22 May 2018)

  New Revision: 61ea014fd73cca9cad8b7d874e8fac0e6e0ecc7e
  https://github.com/groonga/groonga/commit/61ea014fd73cca9cad8b7d874e8fac0e6e0ecc7e

  Message:
    mrb: fix a memory leak of Column#[]

  Modified files:
    lib/mrb/mrb_column.c

  Modified: lib/mrb/mrb_column.c (+7 -3)
===================================================================
--- lib/mrb/mrb_column.c    2018-05-22 14:06:44 +0900 (3b2acab7a)
+++ lib/mrb/mrb_column.c    2018-05-22 14:28:41 +0900 (74047088d)
@@ -53,13 +53,17 @@ mrb_grn_column_array_reference(mrb_state *mrb, mrb_value self)
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
   grn_obj *column;
   mrb_int record_id;
-  grn_obj *column_value;
+  grn_obj column_value;
+  mrb_value mrb_column_value;
 
   column = DATA_PTR(self);
   mrb_get_args(mrb, "i", &record_id);
 
-  column_value = grn_obj_get_value(ctx, column, record_id, NULL);
-  return grn_mrb_value_from_grn_obj(mrb, column_value);
+  GRN_VOID_INIT(&column_value);
+  grn_obj_get_value(ctx, column, record_id, &column_value);
+  mrb_column_value = grn_mrb_value_from_grn_obj(mrb, &column_value);
+  GRN_OBJ_FIN(ctx, &column_value);
+  return mrb_column_value;
 }
 
 static mrb_value
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180522/bb6450db/attachment.htm 



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