[Groonga-commit] groonga/groonga at 484bf1e [master] Fix a memory leak for "VECTOR_COLUMN || xxx" expression

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 20 18:50:15 JST 2013


Kouhei Sutou	2013-05-20 18:50:15 +0900 (Mon, 20 May 2013)

  New Revision: 484bf1e8aff280f5d74be9d5bf3745265a953f8a
  https://github.com/groonga/groonga/commit/484bf1e8aff280f5d74be9d5bf3745265a953f8a

  Message:
    Fix a memory leak for "VECTOR_COLUMN || xxx" expression
    
    There are many operations that have a memory leak. Should we fix all
    of them in the next release? Or later release?

  Added files:
    test/command/suite/select/filter/vector/or.expected
    test/command/suite/select/filter/vector/or.test
  Modified files:
    lib/expr.c

  Modified: lib/expr.c (+5 -4)
===================================================================
--- lib/expr.c    2013-05-20 18:44:08 +0900 (71c95f8)
+++ lib/expr.c    2013-05-20 18:50:15 +0900 (417bd5b)
@@ -3139,14 +3139,15 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs)
       case GRN_OP_OR :
         {
           grn_obj *x, *y;
+          int result;
           POP2ALLOC1(x, y, res);
           if (GRN_INT32_VALUE(x) == 0 && GRN_INT32_VALUE(y) == 0) {
-            GRN_INT32_SET(ctx, res, 0);
+            result = 0;
           } else {
-            GRN_INT32_SET(ctx, res, 1);
+            result = 1;
           }
-          res->header.type = GRN_BULK;
-          res->header.domain = GRN_DB_INT32;
+          grn_obj_reinit(ctx, res, GRN_DB_INT32, 0);
+          GRN_INT32_SET(ctx, res, result);
         }
         code++;
         break;

  Added: test/command/suite/select/filter/vector/or.expected (+46 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/vector/or.expected    2013-05-20 18:50:15 +0900 (ae9df00)
@@ -0,0 +1,46 @@
+table_create Memos TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Memos tags COLUMN_VECTOR ShortText
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"_key": "groonga is very fast", "tags": ["groonga"]},
+{"_key": "no tag"}
+]
+[[0,0.0,0.0],2]
+select Memos --filter 'tags || false'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        1
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "tags",
+          "ShortText"
+        ]
+      ],
+      [
+        1,
+        "groonga is very fast",
+        [
+          "groonga"
+        ]
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/filter/vector/or.test (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/filter/vector/or.test    2013-05-20 18:50:15 +0900 (56bd4c2)
@@ -0,0 +1,10 @@
+table_create Memos TABLE_HASH_KEY ShortText
+column_create Memos tags COLUMN_VECTOR ShortText
+
+load --table Memos
+[
+{"_key": "groonga is very fast", "tags": ["groonga"]},
+{"_key": "no tag"}
+]
+
+select Memos --filter 'tags || false'
-------------- next part --------------
HTML����������������������������...
Download 



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