[Groonga-commit] groonga/groonga [master] dump: fix a memory leak

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Mar 14 22:19:58 JST 2013


Kouhei Sutou	2013-03-14 22:19:58 +0900 (Thu, 14 Mar 2013)

  New Revision: 50db820af25a3b90cf6910d1498610d7a6af330a
  https://github.com/groonga/groonga/commit/50db820af25a3b90cf6910d1498610d7a6af330a

  Message:
    dump: fix a memory leak
    
    Conditions:
    
      * Column is a reference column
      * Column is a vector column
      * Reference key size is 25 byte or larger

  Added files:
    test/command/suite/dump/vector_long_key.expected
    test/command/suite/dump/vector_long_key.test
  Modified files:
    lib/str.c

  Modified: lib/str.c (+2 -1)
===================================================================
--- lib/str.c    2013-03-13 16:01:55 +0900 (2b71ee6)
+++ lib/str.c    2013-03-14 22:19:58 +0900 (4cc7b5d)
@@ -2820,11 +2820,12 @@ grn_text_otoj(grn_ctx *ctx, grn_obj *bulk, grn_obj *obj, grn_obj_format *format)
         GRN_TEXT_PUTC(ctx, bulk, '[');
         if (v < ve) {
           for (;;) {
-            grn_obj key;
             if (range->header.type != GRN_TABLE_NO_KEY) {
+              grn_obj key;
               GRN_OBJ_INIT(&key, GRN_BULK, 0, range->header.domain);
               grn_table_get_key2(ctx, range, *v, &key);
               grn_text_otoj(ctx, bulk, &key, NULL);
+              GRN_OBJ_FIN(ctx, &key);
             } else {
               grn_text_lltoa(ctx, bulk, *v);
             }

  Added: test/command/suite/dump/vector_long_key.expected (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/dump/vector_long_key.expected    2013-03-14 22:19:58 +0900 (185c40e)
@@ -0,0 +1,26 @@
+table_create Tags TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+table_create Users TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Users tags COLUMN_VECTOR Tags
+[[0,0.0,0.0],true]
+load --table Users
+[
+{"_key": "alice",  "tags": ["long (24byte > 0 is long)"]}
+]
+[[0,0.0,0.0],1]
+dump
+table_create Tags TABLE_HASH_KEY ShortText
+table_create Users TABLE_HASH_KEY ShortText
+column_create Users tags COLUMN_VECTOR Tags
+load --table Tags
+[
+["_key"],
+["long (24byte > 0 is long)"]
+]
+load --table Users
+[
+["_key","tags"],
+["alice",["long (24byte > 0 is long)"]]
+]
+

  Added: test/command/suite/dump/vector_long_key.test (+11 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/dump/vector_long_key.test    2013-03-14 22:19:58 +0900 (23bf8d0)
@@ -0,0 +1,11 @@
+table_create Tags TABLE_HASH_KEY ShortText
+
+table_create Users TABLE_HASH_KEY ShortText
+column_create Users tags COLUMN_VECTOR Tags
+
+load --table Users
+[
+{"_key": "alice",  "tags": ["long (24byte > 0 is long)"]}
+]
+
+dump
-------------- next part --------------
HTML����������������������������...
Download 



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